Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
APRProof get_steps optimizations (#4585)
- Calling `nonzero_depth` is (relatively) expensive, when it's done for each pending nodes and we have 50+ pending nodes. This is because it traverses the KCFG to find all paths between the init node and the current node. - We were calling `nonzero_depth` twice unnecessarily. Caches the result in a variable instead. - In most cases, depth will be immediately obvious to be nonzero just from looking at the first edge on the path. In this case, skips the traversal. Also skips the traversal if the nodes we are checking the if the depth between is 0 for if they are the same node. - Tested on `test%kontrol%VetoSignallingTest.testVetoSignallingInvariantsArePreserved4(uint256,uint256,uint256)` from the lido tests. Around 400 nodes in, the sync time is 0.3-0.4 seconds without the optimization. With the optimization it is around 0.015 to 0.04 seconds (although this also depends on the number of pending nodes at any given time). This seems to eliminates the bulk of the sync time when there are a large number of pending nodes (~30+). --------- Co-authored-by: Petar Maksimović <[email protected]>
- Loading branch information