You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
QueryEngine::execute runs the client_server_exchange future (4.9 KB value that Rust creates for the async function) inside a tokio select macro
when Box::pin is used, it puts futures in heap memory via malloc, so that when we move the future, we only copy a pointer
Without Box::pin, the compiler can usually create the future in place, directly in the memory of the select maro (with no copies)
In that spirit, #1396 removed the Box::pin to get rid of the malloc call.
However, that was before we built releases with PGO (#1872).
With PGO, this optimization no longer happens: the compiler no longer creates the future in place, and instead copies the 4.9 KB future into place twice per transaction. In our PGO profiles of the pooler bench, these copies cost ~660 cycles per transaction.
Thus, this PR boxes the future again to save the copies (malloc costs ~100 cycles, a much smaller price to pay).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background:
QueryEngine::executeruns theclient_server_exchangefuture (4.9 KB value that Rust creates for the async function) inside a tokio select macroBox::pinis used, it puts futures in heap memory viamalloc, so that when we move the future, we only copy a pointerBox::pin, the compiler can usually create the future in place, directly in the memory of the select maro (with no copies)In that spirit, #1396 removed the
Box::pinto get rid of themalloccall.However, that was before we built releases with PGO (#1872).
With PGO, this optimization no longer happens: the compiler no longer creates the future in place, and instead copies the 4.9 KB future into place twice per transaction. In our PGO profiles of the pooler bench, these copies cost ~660 cycles per transaction.
Thus, this PR boxes the future again to save the copies (
malloccosts ~100 cycles, a much smaller price to pay).