Skip to content
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

sql: pool some of the processor allocations #88973

Merged
merged 2 commits into from
Sep 30, 2022

Conversation

yuzefovich
Copy link
Member

@yuzefovich yuzefovich commented Sep 28, 2022

sql: clarify closing contract around plan node and row source adapters

This commit cleans up the rowSourceToPlanNode adapter (from the
DistSQL processor to the planNode object) in the following manner:

  • it removes the incorrect call to ConsumerClosed of the wrapped
    input. This call was redundant (because the other side of the adapter
    planNodeToRowSource does the closure too) but was also incorrect since
    it could access the row source that was put back into the sync.Pool (and
    maybe even picked up by another query). See issue 88964 for more details.
  • it removes the checks around non-nil "metadata forwarder". These were
    needed when the local planNode and DistSQL processor engines were merged
    into one about four years ago, but nowadays the adapter always gets
    a non-nil forwarder.

Fixes: #88964.

Release note: None

sql: pool some of the processor allocations

This commit makes it so that we now pool allocations of noop,
planNodeToRowSource, and columnarizer processors. Additionally,
trailing meta callbacks for these three as well as materializers
are changed to not be anonymous functions to further reduce the
allocations.

Fixes: #88525.

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

This commit cleans up the `rowSourceToPlanNode` adapter (from the
DistSQL processor to the planNode object) in the following manner:
- it removes the incorrect call to `ConsumerClosed` of the wrapped
input. This call was redundant (because the other side of the adapter
`planNodeToRowSource` does the closure too) but was also incorrect since
it could access the row source that was put back into the sync.Pool (and
maybe even picked up by another query). See issue 88964 for more details.
- it removes the checks around non-nil "metadata forwarder". These were
needed when the local planNode and DistSQL processor engines were merged
into one about four years ago, but nowadays the adapter always gets
a non-nil forwarder.

Release note: None
This commit makes it so that we now pool allocations of noop,
planNodeToRowSource, and columnarizer processors. Additionally,
trailing meta callbacks for these three as well as materializers
are changed to not be anonymous functions to further reduce the
allocations.

Release note: None
@yuzefovich
Copy link
Member Author

Benchmark results are similar to what we had in #88608 before I had to pull out the last commit.

@yuzefovich yuzefovich marked this pull request as ready for review September 29, 2022 02:08
@yuzefovich yuzefovich requested a review from a team as a code owner September 29, 2022 02:08
@yuzefovich
Copy link
Member Author

The second commit here is an extension of what we had in #88608 (pooling of planNodeToRowSources was added) and the first commit is new.

Copy link
Collaborator

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @DrewKimball)

@yuzefovich
Copy link
Member Author

TFTR!

bors r+

@craig
Copy link
Contributor

craig bot commented Sep 30, 2022

Build succeeded:

@craig craig bot merged commit aaca5ce into cockroachdb:master Sep 30, 2022
@yuzefovich yuzefovich deleted the fix-cleanup branch September 30, 2022 17:37
yuzefovich added a commit to yuzefovich/cockroach that referenced this pull request Oct 10, 2022
This commit removes a stale TODO about investigating why the
materializers could not be released in all cases when they are created
to wrap a row-by-row processor into the vectorized flow. The root cause
was addressed in cockroachdb#88973 (the problem was that we could call
`ConsumerClosed` on an already `Release`d object), so it is now safe to
always release the materializers. For the same reason we no longer need
to perform a deep copy of the closers when creating the materializer.

Additionally, this commit removes a temporary allocation for a slice of
releasables by directly modifying the main "tracking" slice.

Release note: None
craig bot pushed a commit that referenced this pull request Oct 10, 2022
89628: colexec: remove a couple of now-stale TODOs r=yuzefovich a=yuzefovich

This commit removes a stale TODO about investigating why the
materializers could not be released in all cases when they are created
to wrap a row-by-row processor into the vectorized flow. The root cause
was addressed in #88973 (the problem was that we could call
`ConsumerClosed` on an already `Release`d object), so it is now safe to
always release the materializers. For the same reason we no longer need
to perform a deep copy of the closers when creating the materializer.

Additionally, this commit removes a temporary allocation for a slice of
releasables by directly modifying the main "tracking" slice.

Release note: None

Epic: None

Co-authored-by: Yahor Yuzefovich <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants