Perf pure go cairo0 class hash - #3648
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3648 +/- ##
==========================================
+ Coverage 75.96% 76.21% +0.24%
==========================================
Files 395 396 +1
Lines 35780 36424 +644
==========================================
+ Hits 27182 27759 +577
- Misses 6635 6688 +53
- Partials 1963 1977 +14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
574ac2f to
3933b97
Compare
RafaelGranza
left a comment
There was a problem hiding this comment.
Really solid work. The test setup with starknet-rs fixtures and the snapshot are great touches.
Could you walk through the comments before merging? Most are nits or future direction ideas, no blocking items.
|
Sorry, misclicked and updated your branch with a merge instead of a rebase. |
rodrodros
left a comment
There was a problem hiding this comment.
All looking good so far, blocking until I get a good grasp of the code myself
95c9515 to
841e84e
Compare
rodrodros
left a comment
There was a problem hiding this comment.
@ongyimeng looks good, can you add the benchmark tests to the diff as well 🙏
841e84e to
1dd8b46
Compare
Instead of storing in a buffer all the bytes of a Cairo 0 Class, chunk them in a local 4kb buffer that every time it gets filled, it streams it into the Starknet Keccak Digest. Avoiding memory spikes and reducing allocations.
Summary
Replace Cairo0 class hashing with a pure-Go implementation and optimize the path.
Changes
Results
These results are from the benchmark,
BenchmarkClassV0Hash.Runtime improved compared to the latest upstream main Rust/FFI path:
Go memory metrics use the initial pure-Go baseline since Go benchmarks do not count Rust-side FFI allocations.
Go memory metrics improved compared to the initial pure-Go baseline:
Memory tradeoff:
core/crypto).Benchmarks were run on macOS, Intel i5, with
GOMAXPROCS=1Motivation
Issue #2084