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

Reduce aggregation result footprint #5661

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Reduce aggregation result footprint #5661

wants to merge 2 commits into from

Conversation

rdettai
Copy link
Collaborator

@rdettai rdettai commented Jan 30, 2025

Description

Profiling showed that parsing the json serialized aggregation string returned by the root searcher into a serde_json::Value can take 5x time the memory size of the returned payload. On a loaded system, this can represent a lot of memory that is consumed even if results are served from cache.

By using serde_json_borrowed::OwnedValue, we can reduce this tp 3x the size of the returned payload.

How was this PR tested?

Heaptrack profiling.

@rdettai rdettai self-assigned this Jan 30, 2025
@rdettai rdettai requested a review from fulmicoton January 30, 2025 15:20
/// A cousin of [`quickwit_search::SearchResponseRest`] that implements [`Deserialize`]
///
/// This version of the response is necessary because
/// `serde_json_borrow::OwnedValue` is not deserializeable.
Copy link
Contributor

Choose a reason for hiding this comment

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

ah we can ask @PSeitz to make it Deserializable.

Copy link
Contributor

Choose a reason for hiding this comment

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

OwnedValue is a little bit special, because it needs to to take ownership of the original String

Copy link
Contributor

@fulmicoton fulmicoton Jan 30, 2025

Choose a reason for hiding this comment

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

couldn't it be possible to still make it deserializable by keeping a state in the deserializer, and building a (non-original) String with the concatenation of all of the Strings?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that should be possible, but it would require to have a special deserialization logic. Currently it's just a thin wrapper

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I've looked into it and it seemed pretty hairy 😄

Given that we use deserialisation only in one place and that is in the client, I ended up giving up to the dumb solution of having this DTO style object.

@rdettai
Copy link
Collaborator Author

rdettai commented Jan 30, 2025

TODO BEFORE MERGING: add the same thing on the ES API search path

@rdettai rdettai force-pushed the agg-res-footprint branch 2 times, most recently from 622819b to c5d7e86 Compare February 5, 2025 16:14
@rdettai
Copy link
Collaborator Author

rdettai commented Feb 5, 2025

@fulmicoton I made some changes to also use the same borrowed deserialization on the ES API code path. If you could take a look that would be great!

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.

3 participants