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

Querier doesn't put back bytes in the reusable chunk pool #6038

Closed
krasi-georgiev opened this issue Sep 19, 2019 · 7 comments
Closed

Querier doesn't put back bytes in the reusable chunk pool #6038

krasi-georgiev opened this issue Sep 19, 2019 · 7 comments

Comments

@krasi-georgiev
Copy link
Contributor

The chunk dir reader uses a pool but never puts anything back to the pool

return s.pool.Get(chunkenc.Encoding(chk[0]), chk[1:1+chkLen])

I think putting back should happen in the Close method

func (s *Reader) Close() error {
return closeAll(s.cs)
}

cc @codesome this might be interesting to you since you did some memory optimizations recently 😺

@csmarchbanks
Copy link
Member

Relevant PR I did for this a year ago: prometheus-junkyard/tsdb#427, I ended up concluding that it wasn't really worthwhile.

I ran into some subtle bugs that can happen depending on where you try to put chunks back into the pool. Putting a chunk back during close is only slightly helpful since all the intermediate chunks would not be put back.

@codesome
Copy link
Member

From a quick search, I found only these 2 places which calls .Chunk(ref)

c.Chunk, s.err = s.chunks.Chunk(c.Ref)

chk.Chunk, err = c.chunks.Chunk(chk.Ref)

And the chunk pool is passed on by the DB to the Block. So maybe we can pass the same pool in those iterators and put back the old chunks after every iteration. Not sure how much we will benefit from this than just letter the gc collect it away.

@codesome
Copy link
Member

codesome commented Jan 7, 2020

Stumbled upon this while working on head chunks on disk - this would apply to Head as well once we have that work upstream. I'll be attempting to put back into the pool during iteration.

@brian-brazil
Copy link
Contributor

@codesome Is this still relevant?

@codesome
Copy link
Member

Yes. Chunks are only taken out of pool for queries on the blocks. Same is the case with mmapping chunks now. I attempted fixing it but it was very tricky. I haven't attempted further after that.

@codesome
Copy link
Member

Still relevant, hence reopening

@codesome codesome reopened this Mar 30, 2021
@krasi-georgiev
Copy link
Contributor Author

closing for no activity

@prometheus prometheus locked as resolved and limited conversation to collaborators May 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants