-
Notifications
You must be signed in to change notification settings - Fork 85
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(projectconfig): Decompress redis value [INGEST-1505 INGEST-1506] #1345
Conversation
fn parse_redis_response(raw_response: &[u8]) -> Result<ProjectState, RedisProjectError> { | ||
let decoded = metric!(timer(RelayTimers::ProjectStateDecompression), { | ||
zstd::decode_all(raw_response) | ||
}); |
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.
Instead of checking for zstandard's magic number explicitly, I just run decompression here, assuming that the library already efficiently checks if the given blob is in zstandard format. We can use the logged metric to verify this.
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.
that makes sense. I wonder whether zstd::decode_all will allocate a vector in case the payload is not zstd. but i think either way it'll work
}); | ||
|
||
let raw_response: Cow<[u8]> = match decoded { | ||
Ok(decoded) => decoded.into(), |
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.
can't you just borrow here to avoid the Cow?
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.
Yep, thanks.
Record more metrics for the decompression of project config entries in the redis cache (see #1345).
With transaction metrics and dynamic sampling config, the size of the project config values written to redis become a problem at scale. Compression should mitigate this problem.