AleoNet / snarkVM

A Virtual Machine for Zero-Knowledge Executions
https://snarkvm.org
Apache License 2.0
1.08k stars 1.5k forks source link

[Perf] Speed up locking in DataMap::atomic_checkpoint #2506

Open ljedrz opened 4 months ago

ljedrz commented 4 months ago

This is a tiny change I found while pruning my local branches, and I wouldn't want us to miss it.

The guard on atomic_batch is utilized a lot, which - in the current setup - also causes the guard on checkpoints used in the atomic_checkpoint method to be in force significantly longer than necessary.

This tiny change with no impact on logic fixes this, as confirmed by guard lifetime measurements in a --dev run; the maximum guard (on checkpoints) duration is reduced by ~75%.

ljedrz commented 4 months ago

CI run link