-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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/rowflow: excessive memory allocation in setup flow #42770
Comments
@yuzefovich any thoughts? |
We disabled some of the pooling because it was broken, but forgot to re-enable it. We should get back to this. You're not wrong that the lifecycles are kind of tricky - that's why we had the bugs. |
We had some issues with correctly releasing the specs (see #38952), but I think eventually we didn't merge anything that was touching the releasing of the specs. (I quickly took a peek at |
Oh, I see - the diff is slightly messed: |
I addressed points 1 and 3 in #42809 (hopefully, the build is green). I'm not sure about point 2 though. |
42809: sql: pool some allocations during flow setup r=yuzefovich a=yuzefovich **flowinfra: slightly tweak the setup of processors in the flow** Previously, the last processor ('headProc') would be removed from f.processors before flow.startInternal to be run in the same goroutine as the one that is doing the setup. However, this was problematic because if that processor implements 'Releasable' interface, it will not be returned to the pool on the flow clean up. Now this is fixed. Addresses: #42770. Release note: None **sql: pool flow allocations** sql: pool flow allocations Previously, new structs for rowBasedFlow and vectorizedFlow would be allocated upon creation. This commit creates pools for both of them. flowinfra.Releasable interface is moved into execinfra package because now components from rowflow, rowexec, and colflow packages implement that. In order to actually be able to release the flow structs, I needed to create separate Cleanup methods (which still share most of the logic) which allows for removal of vectorized memory monitoring logic from the shared FlowCtx. Release note: None Co-authored-by: Yahor Yuzefovich <yahor@cockroachlabs.com>
Points 1 and 3 have been addressed, and I opened up #55960 for the second point. |
What is your situation?
Looking at a heap profile while running KV95, I observe that 16.12% of allocated space is due to
rowflow.(*rowBasedFlow).Setup
. There are few delinquent things here calls.tableReader
inflow.Cleanup
.The
tableReader
s are allocated from async.Pool
and should be released withRelease
:cockroach/pkg/sql/rowexec/tablereader.go
Line 180 in 78f8482
The
flowinfra.FlowBase
generally releases its underlying processors inCleanup
:cockroach/pkg/sql/flowinfra/flow.go
Line 438 in 78f8482
The problem is that we remove the head processor from
f.processors
inFlowBase.Run
:cockroach/pkg/sql/flowinfra/flow.go
Line 363 in 78f8482
Unfortunately it's not clear that the head processor can be freed with the other processors. The following patch didn't seem to work:
We always construct a new
ImmutableTableDescriptor
. These things are meant to be cached. I'm not sure how best to plumb a cache (or which one).We could pool the
rowBasedFlow
objects (right?).Maybe there's something I'm missing about life cycles which make this pooling hard. Either way, it's the most obvious offender in a memory profile and it seems like mostly low hanging fruit.
The text was updated successfully, but these errors were encountered: