-
Notifications
You must be signed in to change notification settings - Fork 10
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
optimize TLV encoding-decoding #123
Merged
Merged
+6,084
−2,706
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pulsejet
changed the title
[WIP] optimize TLV decoding reader
[WIP] optimize TLV encoding-decoding
Feb 3, 2025
This has a cost - any interests in the expiry period may get dropped?
pulsejet
changed the title
[WIP] optimize TLV encoding-decoding
optimize TLV encoding-decoding
Feb 4, 2025
CI benchmark graphs are live at https://named-data.github.io/ndnd/dev/bench/index.html |
Great progress. Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The idea is similar to #84 with a better approach
WireView
class stays on the stack, and behaves similar to the readers (also it's very well tested, I hope). The downside is that the wire itself is an alloc when using a buffer directly. It may be possible to work around this withunsafe
but doesn't seem worth it.*uint64
. This moves the optional to stack memory with a genericenc.Optional[V]
Added benchmarks for TLV encoding and decoding to this package. Current results (this will likely improve further after bringing in more stuff from #84)
Before (current main branch):
After this PR:
EDIT 1: More memory optimization for name hash
EDIT 2: Since the forwarder does not need to decode all fields in the packet, e.g. signature and content, it can skip some parts of the decoding. Benchmark with this new
FwPacket
which only decodes what is needed: