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

Store-gateway: add support to lazy mmap index-headers #3431

Merged
merged 12 commits into from
Nov 12, 2020

Conversation

pracucci
Copy link
Contributor

@pracucci pracucci commented Nov 11, 2020

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

As discussed during the Thanos community meeting, I would like to propose to add support for lazy mmaping of index-headers in the store-gateway with the ability to automatically unload them after X time of inactivity. This PR aims to do it.

Draft because:

  • CHANGELOG is missing

Verification

Unit tests.

@pracucci pracucci mentioned this pull request Nov 11, 2020
2 tasks
@pracucci pracucci marked this pull request as ready for review November 12, 2020 12:08
@pracucci
Copy link
Contributor Author

OK @bwplotka. I've manually tested it and, so far, I haven't noticed any issue. I think it's ready for a review.

@pracucci
Copy link
Contributor Author

We've tested it on a Cortex cluster where each store-gateway has >65K blocks and we can finally run it without hitting in the max mmap areas kernel limit. It's still a bit slow to startup, but that's another story.

Screenshot 2020-11-12 at 14 35 14

@pracucci
Copy link
Contributor Author

Indexes loaded (green) and indexes unloaded (yellow) with a 15m idle timeout.

Screenshot 2020-11-12 at 14 37 12

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Amazing, generally LGTM, just style/readability things to improve 💪

Thanks!

CHANGELOG.md Outdated Show resolved Hide resolved
cmd/thanos/store.go Outdated Show resolved Hide resolved
lazyIndexReaderEnabled := cmd.Flag("store.enable-index-header-lazy-reader", "If true, Store Gateway will lazy memory map index-header only once required by a query.").
Hidden().Default("false").Bool()

lazyIndexReaderIdleTimeout := cmd.Flag("store.index-header-lazy-reader-idle-timeout", "If index-header lazy reader is enabled and this idle timeout setting is > 0, memory map-ed index-headers will be automatically released after 'idle timeout' inactivity.").
Copy link
Member

Choose a reason for hiding this comment

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

This can stay hidden, maybe not sure if needed to be tweaked (less flags = simler to use thing is )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would suggest to keep the hidden flag, to allow all of us to experiment with that and find a better idle timeout. I just put a "random" value so far.

pkg/block/indexheader/lazy_binary_reader.go Show resolved Hide resolved
pkg/block/indexheader/lazy_binary_reader.go Outdated Show resolved Hide resolved
pkg/block/indexheader/lazy_binary_reader.go Outdated Show resolved Hide resolved
pkg/block/indexheader/lazy_binary_reader.go Outdated Show resolved Hide resolved
pkg/block/indexheader/lazy_binary_reader.go Outdated Show resolved Hide resolved
pkg/block/indexheader/reader_pool.go Show resolved Hide resolved
pkg/block/indexheader/reader_pool.go Outdated Show resolved Hide resolved
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
@pracucci
Copy link
Contributor Author

@bwplotka Thanks for the review! I've address your comments or commented otherwise. Could you take another look, please?

Signed-off-by: Marco Pracucci <marco@pracucci.com>
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

LGTM! 💪

@bwplotka bwplotka merged commit 05fbe15 into thanos-io:master Nov 12, 2020
@pracucci pracucci deleted the lazy-index-header-reader branch November 12, 2020 17:36
Oghenebrume50 pushed a commit to Oghenebrume50/thanos that referenced this pull request Dec 7, 2020
* Experimental lazy index-header reader

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* Implemented lazy index-header reader

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* Renamed CLI flags

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* Added copyright to new files

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* Track metrics in the lazy index-header reader

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* Ensure BucketStore.Close() is called in tests

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* Ensure BucketStore.Close() is called in e2e tests too

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* Shorten metric names

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* Added CHANGELOG entry

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* Addressed review comments

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* Removed readerTracker

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* Fixed test and comments

Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Oghenebrume50 <raphlbrume@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants