Commit 8fc24bd
committed
Merge #6734: perf: temporary cache for consequent calls of CDeterministicMNList for historical blocks
366cd2b refactor: clarify logic and add a named constant MINI_SNAPSHOT_INTERVAL (Konstantin Akimov)
bfca726 perf: do not create mini-snapshots during re-index (Konstantin Akimov)
38513b6 perf: temporary cache for consequent calls of CDeterministicMNList for historical blocks (Konstantin Akimov)
Pull request description:
## Issue being fixed or feature implemented
Each call of `CDeterministicMNManager::GetListForBlock` for historical block can require up to 575 diff applying from snapshot.
Consequent calls for close blocks repeat this calculation twice.
## What was done?
This PR abuses `mnListsCache` by adding mini-snapshot each 32 blocks between snapshots in database (each 576 blocks).
Downside of this solution: extra RAM usage.
Though, this cache is cleaned every 10 seconds by `CDeterministicMNManager::DoMaintenance`, so, the RAM usage is temporary.
## How Has This Been Tested?
It speeds up RPC `protx diff` up to 8x.
`develop`:
```
$ time ( for j in $(seq 500) ; do src/dash-cli protx diff $((2121000+$j)) $((2121000+$j+1)) ; done ) > /dev/null
real 0m47,743s
user 0m0,472s
sys 0m1,467s
```
PR:
```
$ time ( for j in $(seq 500) ; do src/dash-cli protx diff $((2121000+$j)) $((2121000+$j+1)) ; done ) > /dev/null
real 0m6,032s
user 0m0,423s
sys 0m1,300s
```
It speeds ups blocks's Undo up to 10x; measured by calling `invalidateblock blockhash` where blockhash is distant block, far from the tip (500+).
## Breaking Changes
N/A
## Checklist:
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone
ACKs for top commit:
UdjinM6:
LGTM, utACK 366cd2b
Tree-SHA512: 1880783916394b6f45a0e71dc59c454766bff498df62cc4642dfa4e8a53736de2ac7c180397584572b4c21a651f65b26cb832c7e4cf2d4b9599556f58bda621e1 file changed
+18
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
779 | 780 | | |
780 | 781 | | |
781 | 782 | | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
782 | 800 | | |
783 | 801 | | |
784 | 802 | | |
| |||
0 commit comments