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

Deserialize CBOR data without one allocation per value #772

Merged
merged 1 commit into from
Jul 13, 2024

Conversation

vkrause
Copy link
Member

@vkrause vkrause commented Jul 13, 2024

QCBorValue::toJsonValue checks whether the CBOR data is in the JSON subset, which results in one allocation per value. As this is our own serialized data here, we don't need that check and can use the CBOR data directly.

The API for that fast path is unfortunately not public, but it's inline code, so it doesn't bind us to Qt's unstable internal ABI either.

This saves about 12M allocations during the startup of Itinerary here.

QCBorValue::toJsonValue checks whether the CBOR data is in the JSON subset,
which results in one allocation per value. As this is our own serialized
data here, we don't need that check and can use the CBOR data directly.

The API for that fast path is unfortunately not public, but it's inline
code, so it doesn't bind us to Qt's unstable internal ABI either.

This saves about 12M allocations during the startup of Itinerary here.
@KitsuneRal KitsuneRal added the enhancement A feature or change request for the library label Jul 13, 2024
@KitsuneRal
Copy link
Member

Ah yes, I've seen fromTrustedCbor() but didn't know how to use it; and yes the inefficiency has always bugged me too. Thanks for the trick!

@KitsuneRal KitsuneRal merged commit d8bfeed into quotient-im:dev Jul 13, 2024
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature or change request for the library
Projects
Status: 0.9 - Done
Development

Successfully merging this pull request may close these issues.

2 participants