Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Reduce aggregation result footprint #5661

Merged
merged 2 commits into from
Feb 6, 2025
Merged

Reduce aggregation result footprint #5661

merged 2 commits into from
Feb 6, 2025

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
Collaborator

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
Collaborator

@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!

@guilload guilload merged commit 7bc495a into main Feb 6, 2025
8 checks passed
@guilload guilload deleted the agg-res-footprint branch February 6, 2025 15:26
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants