Coming to Mainnet on Jan 15!
Over the last few weeks, internal stress-testing revealed several openings for performance improvements: some Python code begging to be replaced with Rust, an optimization of the
ec_op builtin to use projective coordinates instead of affine coordinates, and some caching.
After concentrated efforts, all of these improvements were implemented. Before diving into the results, an important schedule clarification:
- The Mainnet upgrade date of Jan 10, 2024 did not include these performance improvements. The holdup is due to our wish to run these changes a few more days on testnet.
- These performance improvements will be included in an additional Mainnet upgrade, which will take place on Jan 15, 2024.
Now here is what you all want to see: below is a table detailing the results of the various optimizations that were done. The example we choose is for
|Cairo0 account & token contract
|Cairo account & token contract
There are several caveats to be made:
- As you can see, there is a gap in performance between Cairo0 and Cairo. The gap is due to the powerful safety properties provided by Sierra. However, as shown in the table, it can be reduced considerably by careful optimization. Following the optimizations, the gap between Cairo0 and Cairo was halved largely thanks to the
ec_opoptimization which accelerated the validate of the Cairo accounts used in our testing. Indeed the tested Cairo0 accounts used the
ECDSAbuiltin which is illegal in Sierra (and therefore Cairo) as it can fail.
- Throughput in practice depends on many factors. A major one is the % of the block using
ec_op, which enjoys a roughly 60x speedup. This means a block with few such validate functions, or few multicalls to such accounts, will exhibit a smaller speedup compared to the erc20_transfer scenario with many separate transactions.
- In particular, since the “pure” scenario of transfers is not the standard traffic on Starknet, the practical throughput improvement on Mainnet will likely be less drastic in the average case.