Optimise SSZ encoding and decoding - #55
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #55 +/- ##
==========================================
- Coverage 57.18% 57.10% -0.09%
==========================================
Files 10 10
Lines 313 345 +32
==========================================
+ Hits 179 197 +18
- Misses 134 148 +14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Unfortunately yes the Miri flags it as UB and the test also fails (we decode integers like 2 "successfully" as bools) |
|
Gonna try using |
|
Ok nice, we didn't actually need an |
|
Updated the benchmark results in the OP, there are some slower benches for encoding, but I think this is just noise. We haven't changed the encoding codepath at all. |
paulhauner
left a comment
There was a problem hiding this comment.
All the unsafe stuff looks good to me 👍
I don't understand the chunks to chunks_exact change, but perhaps I'm missing something.
I think this is overall a worthwhile improvement and the added unsafe code is (a) small enough to be easily reasoned about and (b) worth reasoning about.
Co-authored-by: Paul Hauner <paul@paulhauner.com>
Summary of changes
unsafefast path for decoding lists and vectors ofu8chunks_exactand an explicit loop instead oftry_fold.Benchmarks
Additional Info
Depends on a new release of
ethereum_sszfor:Encoding is not meaningfully faster, but would need to be optimised in
sszitself (we need to optimise theVecimpl).