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

Add basic optimizations for allocations in OER #323

Merged
merged 9 commits into from
Sep 15, 2024

Conversation

Nicceboy
Copy link
Contributor

@Nicceboy Nicceboy commented Sep 14, 2024

Lack of pre-allocations and not using existing buffers created many unnecessary allocations.

This will reduces them a bit.
I trialed several data types for output buffer, and

output: alloc::borrow::Cow<'a, RefCell<Vec<u8>>>,

seems to be best. I tried sharing direct reference of Vec<u8> and also Bytes/BytesMut.
Direct reference was too difficult to add since encoder uses itself recursively. BytesMut was much slower. Maybe this is okay for a while.

Now the buffer is re-used when possible. e.g. no length calculation requirement afterwards.

Current improvement based on the integer test:

image

@XAMPPRocky
Copy link
Collaborator

Thank you for your PR!

@XAMPPRocky XAMPPRocky merged commit c2fc4fd into librasn:main Sep 15, 2024
65 checks passed
@github-actions github-actions bot mentioned this pull request Sep 15, 2024
@Nicceboy Nicceboy deleted the oer-buffer-add branch September 15, 2024 11:57
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.

2 participants