Commit 4a1b19b
Merge dashpay#6680: perf: avoid heavy object copy during ApplyDiff for CDeterministicMNList
73b68fe perf: avoid heavy object copy during ApplyDiff for CDeterministicMNList (Konstantin Akimov)
Pull request description:
## Issue being fixed or feature implemented
The function `ApplyDiff` for CDeterministicMNList creates copy of current object and return it.
It is not efficient in case of applying several diffs one after one.
In case if `UndoBlock` and in case of calculating Quorum Members for old blocks (without caches) up to 576 temporary copies of CDeterministicMNList may be created and destroyed.
## What was done?
`ApplyDiff` now changes current object, not returning a copy.
It speed ups calculation of GetDeterministicMNListInternal for ~10%; this helper is most hot function during:
- block undo
- RPC `quorum info` for distant quorums (when it's not in cache).
- RPC `quorum verify` for distant quorums (when it's not in cache)
## How Has This Been Tested?
Run unit / functional tests
Collected `perf` stats for block-undo.
develop:
<img width="772" alt="image" src="https://github.com/user-attachments/assets/a74e5dbb-314e-4067-b0dc-372235d37fb5" />
PR:
<img width="772" alt="image" src="https://github.com/user-attachments/assets/a587cb6d-96f1-4932-9143-90b7a08b2751" />
## Breaking Changes
n/a
## Checklist:
- [x] I have performed a self-review of my own code
- [ ] 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:
ACK 73b68fe
PastaPastaPasta:
utACK 73b68fe
Tree-SHA512: cd82e35bdef6793d5bb0ea2189a66b01e50f318dbefd0283dab2973f6df8d99a731cef7b49aed5e8f9ca54c2282ab5570a35224e34c6d10447caeb9e097a31e51 parent 3513d91 commit 4a1b19b
File tree
3 files changed
+29
-28
lines changed- src
- evo
- test
3 files changed
+29
-28
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
375 | | - | |
| 375 | + | |
376 | 376 | | |
377 | | - | |
378 | | - | |
379 | | - | |
| 377 | + | |
| 378 | + | |
380 | 379 | | |
381 | 380 | | |
382 | | - | |
| 381 | + | |
383 | 382 | | |
384 | 383 | | |
385 | 384 | | |
386 | | - | |
| 385 | + | |
387 | 386 | | |
388 | 387 | | |
389 | | - | |
| 388 | + | |
390 | 389 | | |
391 | 390 | | |
392 | | - | |
| 391 | + | |
393 | 392 | | |
394 | 393 | | |
395 | 394 | | |
396 | | - | |
| 395 | + | |
397 | 396 | | |
398 | | - | |
399 | | - | |
400 | 397 | | |
401 | 398 | | |
402 | 399 | | |
| |||
624 | 621 | | |
625 | 622 | | |
626 | 623 | | |
627 | | - | |
| 624 | + | |
| 625 | + | |
628 | 626 | | |
629 | 627 | | |
630 | 628 | | |
| |||
1007 | 1005 | | |
1008 | 1006 | | |
1009 | 1007 | | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
1013 | | - | |
1014 | | - | |
1015 | | - | |
| 1008 | + | |
1016 | 1009 | | |
1017 | 1010 | | |
1018 | 1011 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
383 | | - | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
384 | 389 | | |
385 | 390 | | |
386 | 391 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
366 | 366 | | |
367 | 367 | | |
368 | 368 | | |
369 | | - | |
| 369 | + | |
| 370 | + | |
370 | 371 | | |
371 | | - | |
| 372 | + | |
372 | 373 | | |
373 | 374 | | |
374 | 375 | | |
| |||
389 | 390 | | |
390 | 391 | | |
391 | 392 | | |
392 | | - | |
393 | | - | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
394 | 396 | | |
395 | 397 | | |
396 | 398 | | |
397 | 399 | | |
398 | | - | |
399 | | - | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
400 | 403 | | |
401 | | - | |
| 404 | + | |
402 | 405 | | |
403 | | - | |
| 406 | + | |
404 | 407 | | |
405 | | - | |
| 408 | + | |
406 | 409 | | |
407 | 410 | | |
408 | 411 | | |
| |||
0 commit comments