-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
colexec: fix performance inefficiency in materializer #48669
Conversation
We mistakenly were passing `sqlbase.DatumAlloc` by value, and not by pointer, and as a result we would always be allocating 16 datums but using only 1 - i.e. we were not only not pooling the allocations, but actually making a bunch of useless allocations as well. This inefficiency becomes noticeable when the vectorized query returns many rows and when we have wrapped processors and those processors get a lot of input rows - in all cases when we need to materialize a lot. For example, TPC-H query 16 sees about 10% improvement (it returns 18k rows) and TPC-DS query 6 sees 2x improvement (it has wrapped hash aggregator with a decimal column) with this fix. Release note (performance improvement): A performance inefficiency has been fixed in the vectorized execution engine which results in speed ups on all queries when run via the vectorized engine, with most noticeable gains on the queries that output many rows.
LGTM! Nice find! (I guess there are some problems w/ nocopy, but this is great) |
Yeah, my second commit was WIP - I was lazy to run the linter myself, and now I updated the second commit to appease the linter (nothing bad was shaken out, but I think it is beneficial to have RFAL. |
❌ The GitHub CI (Cockroach) build has failed on 6a3dc88d. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
This commit adds `_ util.NoCopy` to `DatumAlloc` struct to prevent us from misusing it. A few places failed the linter, and those have been addressed, but there was no performance problems AFAICT due to the removed copies by value. Release note: None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
complete! 1 of 0 LGTMs obtained (waiting on @asubiotto)
TFTR! bors r+ |
Merge conflict (retrying...) |
Build failed (retrying...) |
Build succeeded |
colexec: fix performance inefficiency in materializer
We mistakenly were passing
sqlbase.DatumAlloc
by value, and not bypointer, and as a result we would always be allocating 16 datums but
using only 1 - i.e. we were not only not pooling the allocations, but
actually making a bunch of useless allocations as well.
This inefficiency becomes noticeable when the vectorized query returns
many rows and when we have wrapped processors and those processors get
a lot of input rows - in all cases when we need to materialize a lot.
For example, TPC-H query 16 sees about 10% improvement (it returns 18k
rows) and TPC-DS query 6 sees 2x improvement (it has wrapped hash
aggregator with a decimal column) with this fix.
Release note (performance improvement): A performance inefficiency has
been fixed in the vectorized execution engine which results in speed ups
on all queries when run via the vectorized engine, with most noticeable
gains on the queries that output many rows.
sqlbase: prohibit copying DatumAlloc by value
This commit adds
_ util.NoCopy
toDatumAlloc
struct to prevent usfrom misusing it. A few places failed the linter, and those have been
addressed, but there was no performance problems AFAICT due to the
removed copies by value.
Release note: None