Commit 60dda51
Merge dashpay#7176: perf: do linear lookup instead building 2 heavy Hash-Maps
6ffe808 refactor: apply review suggestions (Konstantin Akimov)
bb6facd perf: do linear lookup when it's needed instead building 2 heavy Hash-Maps which used almost never (Konstantin Akimov)
9d26734 refactor: remove unused getObjLocalValidity (Konstantin Akimov)
Pull request description:
## Issue being fixed or feature implemented
Currently, for each update of masternode list 3 list are generated: list of shared_pointers, hash-map by service, hash-map by protx.
Creating these hash-maps creates overhead for every user for every masternode update. It causes excessive battery use, excessive RAM usage while these lookups happens in rare conditions (only for masternode owners during voting; only when "Peer Detail" is open).
It's better to do linear lookup _once_ over all masternode in the specific scenario, rather than build these heavy objects for _every_ update of list.
Lookup during voting may looks scary due to potential O(N^2). Though, it's not N^2, but N*M (where M is amount of masternodes that belongs to single Owner, M<<N). Secondly, N is relatively small and _voting_ is not assumed to be rapid-fast action (milliseconds); it's okay if user will wait extra 10ms in the worst case scenario for each its vote.
## What was done?
Code is updated to do linear lookup instead building heavy hash-maps for every update.
Current implementation (in develop) has a bug with dangling pointer and potentially could cause UB: dashpay#7118 (comment)
Fixed by this PR
## How Has This Been Tested?
N/A
## 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 _(for repository code-owners and collaborators only)_
ACKs for top commit:
UdjinM6:
utACK 6ffe808
kwvg:
utACK 6ffe808
Tree-SHA512: b401d399767825a0363edfe8aa89dd6f1c44184874ec40aeebcde36917b643d69bc8a670f3b6e6aaa9a35af88d30810e55413137a8c02955103fca89a46e0c0a1 parent df1ca87 commit 60dda51
File tree
10 files changed
+20
-48
lines changed- src
- interfaces
- node
- qt
- test/util/data
10 files changed
+20
-48
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
204 | 203 | | |
205 | 204 | | |
206 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
152 | 151 | | |
153 | 152 | | |
154 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | 266 | | |
275 | 267 | | |
276 | 268 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
188 | 187 | | |
189 | 188 | | |
190 | 189 | | |
191 | | - | |
192 | | - | |
193 | | - | |
| 190 | + | |
194 | 191 | | |
195 | 192 | | |
196 | 193 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
| 154 | + | |
| 155 | + | |
158 | 156 | | |
159 | 157 | | |
160 | 158 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
534 | 539 | | |
535 | 540 | | |
536 | 541 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
576 | 576 | | |
577 | 577 | | |
578 | 578 | | |
579 | | - | |
580 | | - | |
581 | | - | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
582 | 585 | | |
583 | 586 | | |
584 | 587 | | |
585 | 588 | | |
586 | 589 | | |
587 | 590 | | |
588 | | - | |
| 591 | + | |
589 | 592 | | |
590 | 593 | | |
591 | 594 | | |
| |||
595 | 598 | | |
596 | 599 | | |
597 | 600 | | |
598 | | - | |
599 | | - | |
| 601 | + | |
600 | 602 | | |
601 | 603 | | |
602 | 604 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
| |||
1291 | 1290 | | |
1292 | 1291 | | |
1293 | 1292 | | |
1294 | | - | |
1295 | | - | |
| 1293 | + | |
| 1294 | + | |
1296 | 1295 | | |
1297 | 1296 | | |
1298 | | - | |
1299 | | - | |
| 1297 | + | |
| 1298 | + | |
1300 | 1299 | | |
1301 | 1300 | | |
1302 | 1301 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
| |||
0 commit comments