-
-
Notifications
You must be signed in to change notification settings - Fork 51
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 lifetime for encoder
trait and add allocation improvements based on that (OER)
#370
Conversation
9a396aa
to
b1affa2
Compare
Can you make tracking issues for this and other optimisations that have so far only been implemented for OER? I feel like the other codecs have a lot of catch up to do. |
I can add some notes later. Currently the primary focus have been just on attempting to reduce the allocations for theoretical minimum. |
0ccf5a7
to
6b86240
Compare
This will be likely the last performance optimization for OER in a while, after this PR it is around 20-30% faster than asn1c. |
7782d7d
to
768d909
Compare
b02ed36
to
7e80b86
Compare
7e80b86
to
e6ff9dd
Compare
encoder
trait and add allocation improvements based on thatencoder
trait and add allocation improvements based on that (OER)
Thank you for your PR! |
If we add lifetime for
Encoder
trait, we can recursively share the same output buffer for new encoders with the help ofAnyEncoder
associated type, without usingRefCell
andRc
combination.We can avoid the runtime performance of
RefCell
and can guarantee that mutable reborrow does not happen in compile time.Currently only OER does this, but it applies for other codecs too, if they will be also optimized.
I was also planning on adding
encode_buf
method for OER to reuse the same buffer, since it is trivial after this change, and maybe we can add something like that for other codecs too in small steps.