Improve sexp_buffer_from_stream
performance
#100
Merged
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.
Summary
When I develop clvm-js as a JavaScript implementation of
clvm
, I was suffered in poor performance intest_very_deep_tree
attests/serialize_test
.Later I found out that the root cause was huge number of memory allocation/copy invoked upon byte deserialization of sexp instance.
Looking back to
clvm
of original Python implementation, I noticed that one of the optimizations I applied to my JavaScript implementation can also be applied to the Python's.So here I am proposing the pure performance enhancement of
sexp_buffer_from_stream
.Performance measurement
Test environment
Result
Roughly 10-20% faster than before.
test_very_deep_tree
P.S.
If you're interested, I also compared performance between
clvm
of Python andclvm
of JavaScript.Test execution
Python
JS
Result
test_very_deep_tree
test_very_long_blobs