Draft
Conversation
Member
Author
|
Opened as a draft as it's a useful performance comparison but we may not want to merge it. Longer term we may just want to rip the guts out of another implementation to do the serialization/deserialization as it's the least interesting thing about this module. |
The current implementation loops over message fields and each field
encoder creates a `Uint8Array` which is added to a `Uint8ArrayList`
and stitched together at the end of the process.
Other implementations compute the expected length of the serialized
message, allocate a buffer that size then have encoders write their
data into it at the correct offsets.
This PR makes protons compute the final message buffer size first in
the same way.
Thing is, it doesn't seem to make a huge amount of difference to performance.
Before:
```
Running "Encode/Decode" suite...
Progress: 100%
pbjs:
12 166 ops/s, ±3.92% | 5.12% slower
protons:
9 755 ops/s, ±2.19% | slowest, 23.93% slower
protobufjs:
12 823 ops/s, ±2.02% | fastest
Finished 3 cases!
Fastest: protobufjs
Slowest: protons
```
After:
```
Running "Encode/Decode" suite...
Progress: 100%
pbjs:
11 866 ops/s, ±3.43% | 2.05% slower
protons:
9 356 ops/s, ±2.45% | slowest, 22.77% slower
protobufjs:
12 114 ops/s, ±2.16% | fastest
Finished 3 cases!
Fastest: protobufjs
Slowest: protons
```
82cfa14 to
fecfedd
Compare
ecfb76d to
942e050
Compare
This file contains hidden or 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
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 current implementation loops over message fields and each field encoder creates a
Uint8Arraywhich is added to aUint8ArrayListand stitched together at the end of the process.Other implementations compute the expected length of the serialized message, allocate a buffer that size then have encoders write their data into it at the correct offsets.
This PR makes protons compute the final message buffer size first in the same way.
Thing is, it doesn't seem to make a huge amount of difference to performance.
Before:
After: