-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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(bloomstore): Introduce specialised cache for blocks #12257
Conversation
2771174
to
b99d663
Compare
The blocks cache is an in-memory cache that represents the single source of truth of what blocks are available on the filesystem and manages their EOL lifecycle. Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
b99d663
to
d66c174
Compare
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Regarding commit a1ad00d Before:
After:
|
Signed-off-by: Christian Haudum <[email protected]>
_, found = cache.Get(ctx, "b") | ||
require.False(t, found) | ||
|
||
require.Equal(t, int64(8), cache.currSizeBytes) |
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.
I'd add here another key which is older than b but has a refcount and therefore shouldn't be evicted.
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.
there is actually a bug in the LRU eviction job
|
||
// write | ||
for k, v := range entries { | ||
err := cache.Store(ctx, []string{k}, []BlockDirectory{v}) |
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.
nit: IIUC this is the cache that we want to replace with the new implementation. Maybe we can rename the new PutMany
by Store
so we don't need to change it wherever we use it.
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.
In the bloomstore we use only ever use Put()
to add a single entry.
In the benchmark I wanted to make the calls the same, though.
require.NoError(t, err) | ||
|
||
err = cache.Put(ctx, "key", CacheValue("b", 10)) | ||
require.ErrorContains(t, err, "entry already exists: key") |
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.
nit: maybe we can use errAlreadyExists
right away so if one changes, the test does as well.
|
||
ctx := context.Background() | ||
|
||
_ = cache.Put(ctx, "a", CacheValue("a", 5)) |
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.
I think we should test PutInc
here.
return nil | ||
} | ||
|
||
// NewFsBlocksCache returns a new initialised BlocksCache with the key and value of requested types. |
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.
I think this comment is outdated
return entry.Value, true | ||
} | ||
|
||
func (c *BlocksCache) get(_ context.Context, key string) *Entry { |
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.
if ctx is unused, I think we should remove it.
close(c.done) | ||
} | ||
|
||
func (c *BlocksCache) sizeOf(entry *Entry) int64 { |
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.
nit: I' rather use entry.Value.Size()
right away instead of this method.
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
The blocks cache is an in-memory cache that represents the single source of truth of what blocks are available on the file system and manages their end-of-life behaviour. There is a follow-up branch to wire up the new cache, based on this branch. Signed-off-by: Christian Haudum <[email protected]>
The blocks cache is an in-memory cache that represents the single source of truth of what blocks are available on the file system and manages their end-of-life behaviour. There is a follow-up branch to wire up the new cache, based on this branch. Signed-off-by: Christian Haudum <[email protected]>
What this PR does / why we need it:
The blocks cache is an in-memory cache that represents the single source of truth of what blocks are available on the file system and manages their EOL lifecycle.
Special notes for your reviewer:
There is a follow-up branch to wire up the new cache, based on this branch. See https://github.com/grafana/loki/compare/chaudum/blocks-cache-impl?expand=1