-
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
Loki: Enable FIFO cache by default #4519
Loki: Enable FIFO cache by default #4519
Conversation
3c77808
to
9d84947
Compare
9b1a25f
to
66b9c0d
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.
Docs change of the default values LGTM.
4bfa44c
to
b014756
Compare
Signed-off-by: Mauro Stettler <mauro.stettler@gmail.com>
- We noticed that we always want that behavior, so the logic is better implemented in the `ApplyDinamicConfig` method - Update documentation
- Move FIFO cache default behavior implementation to ApplyDinamicConfig
5e092bb
to
cdd3c01
Compare
@@ -21,41 +21,41 @@ import ( | |||
"github.com/grafana/loki/pkg/util/cfg" | |||
) | |||
|
|||
func Test_ApplyDynamicConfig(t *testing.T) { | |||
testContextExposingErrs := func(configFileString string, args []string) (error, ConfigWrapper, ConfigWrapper) { |
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.
Here I'm moving this block to a separate function to reuse it in other tests.
edit: I've also moved the returned error from first to last param
- The tests tests the behavior of the four existing caches (query results, query index, write dedupe, and chunk results) - Add changelog entry - Fix lint issues regarding import order - Revert moving of EnableFifoCache check
cdd3c01
to
afcaee8
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.
Still thinking about this one. I don't think we'll want write_dedupe_cache to automatically be enabled: it's unused with boltdb shipper and is only helpful coordinating which chunks have been flushed between multiple nodes (local fifo cache isn't helpful here). I'm leaning towards just enabling this for chunks
,index
, and query-results
caches. Then again, enabling a local write-dedupe-cache won't do anything aside take some cpu cycles and memory, so it may just be simpler to eat the performance hit for config simplicity. WDYT @slim-bean ?
} | ||
} | ||
|
||
// isRedisSet is a duplicate of cache.IsRedisSet. |
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 the structs are identical, can we instead just call lokicache.IsRedisSet(cortexcache.RedisConfig(config))
? That would also be less likely to cause errors in the future as we extend the code. Instead, it would cause compiler errors which we could fix.
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.
Wow that looks cool. I'll try it, let's see.
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.
Oh, it didn't work for a similar reason :(
It conflicts because "github.com/cortexproject/cortex/pkg/chunk/cache".RedisConfig) != "github.com/grafana/loki/pkg/storage/chunk/cache".RedisConfig
.
edit: In short: even if the structs are exactly the same, you can't just cast them because in essence they are different types (for being in different packages). One solution that I can think of is expecting a interface{}
and then casting to cortexcache.Config
and if it doesn't work, casting to lokicache.Config
, but that looks weird/too much.
edit2: snippet:
func IsRedisSet(genericCfg interface{}) bool {
if cortexCfg, ok := genericCfg.(cortexcache.Config); ok {
return cortexCfg.RedisConfig.Address != ""
}
if lokiCfg, ok := genericCfg.(lokicache.Config); ok {
return lokiCfg.RedisConfig.Address != ""
}
return false
}
The local cache is set to only be enabled by default for chunk store and for query results (so yeah, no default cache for |
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.
Upon further thinking, we don't want the index cache to be enabled by default because we don't want the ingester to cache these queries when it's configured to query the store. Let's add a couple tests to ensure we're not setting FIFO caches for the index or write_dedupe caches even when no other cache is set for those, then LGTM!
- Change `EnableFifoCache` description to mention that it is only applied for chunk and query results cache Co-authored-by: Owen Diehl <ow.diehl@gmail.com>
WDYT of the tests at lines 716 and 748 from |
Ah, I didn't catch that case. Nice work :) |
Co-Authored-By: Mauro Stettler mauro.stettler@gmail.com
What this PR does / why we need it:
validity
and for the FIFO cache'smax-size-bytes
Which issue(s) this PR fixes:
N/A
Special notes for your reviewer:
Checklist