-
Notifications
You must be signed in to change notification settings - Fork 919
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
feat(share/eds): Rework accessor cache #2612
Conversation
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.
First lookthrough, looking good so far
- update metrics - fix tests
# Conflicts: # share/eds/blockstore.go # share/eds/store.go
- fix merge conflicts
c870854
to
c6e7693
Compare
Needs rework, will update soon. |
458665d
to
8117867
Compare
8117867
to
0a2354f
Compare
# Conflicts: # share/eds/metrics.go
# Conflicts: # share/eds/accessor_cache.go # share/eds/metrics.go # share/eds/store.go
4a8e1bf
to
c7308c5
Compare
6c06553
to
0dfb514
Compare
0dfb514
to
535a418
Compare
6c46937
to
cee7338
Compare
Codecov Report
@@ Coverage Diff @@
## main #2612 +/- ##
==========================================
+ Coverage 51.37% 51.56% +0.18%
==========================================
Files 159 162 +3
Lines 10699 10755 +56
==========================================
+ Hits 5497 5546 +49
- Misses 4723 4726 +3
- Partials 479 483 +4
|
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.
This is looking really good, and I noticed a ton of small cleanups that I really appreciate <3
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.
This is looking really good, and I noticed a ton of small cleanups that I really appreciate <3
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.
Glanced over this for learning purposes, got only one comment/question.
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.
a little optimization
c92b0ab
to
795735a
Compare
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.
Trying this review format that app team uses a lot
- track close errors in metrics - move BlockstoreCloser and readCloser to utils - add comment for sleep in test
- make errCacheMiss private - fix go.mod
**Motivation** Previously, all accessors went into cache. They were closed only when they were evicted from it and there was no way to manually close one. Now, when we need to cache accessors only in some cases and in some not to, this approach will not work. Enabling control of accessor close required major cache rework. New cache features: - Old cache didn't allow to close and release of an accessor. Now, Instead of returning just a reader/blockstore, cache returns object that composed of builder and `io.Closer` (Accessor interface). This allows caller to have an ability to close and release accessor once it is done with reading from it. - Items stored in cache also provide io.Closer`, but it is noop. Lifecycle of cached items is controlled by cache itself. For now objects are released right after they are evicted from cache, but it could be changed to smarter release based on current readers count. Will be implemented as separate issue. - Lazy blockstore builder. Old cache created blockstore every time accessor was acquired, even when only reader was used and blockstore was not needed. Creating blockstore is costly operation that involves building index, so this was reworked to create blockstore, only when it is requested and store it for subsequent requests. - adds cache unit tests. - adds metrics for cache methods to track cache hits/miss. - general cleanup of unused methods/logic. It will be easier for reviewer to start from `store.go` and `blockstore.go` and then go into new `cache` pkg
Motivation
Previously, all accessors went into cache. They were closed only when they were evicted from it and there was no way to manually close one. Now, when we need to cache accessors only in some cases and in some not to, this approach will not work. Enabling control of accessor close required major cache rework.
New cache features:
io.Closer
(Accessor interface). This allows caller to have an ability to close and release accessor once it is done with reading from it.It will be easier for reviewer to start from
store.go
andblockstore.go
and then go into newcache
pkg