Commit 5d6f6fd
committed
Merge bitcoin/bitcoin#31490: refactor: inline
223081e scripted-diff: rename block and undo functions for consistency (Lőrinc)
baaa3b2 refactor,blocks: remove costly asserts and modernize affected logs (Lőrinc)
fa39f27 refactor,blocks: deduplicate block's serialized size calculations (Lőrinc)
dfb2f9d refactor,blocks: inline `WriteBlockToDisk` (Lőrinc)
42bc491 refactor,blocks: inline `UndoWriteToDisk` (Lőrinc)
86b85bb bench: add SaveBlockBench (Lőrinc)
34f9a01 refactor,bench: rename bench/readblock.cpp to bench/readwriteblock.cpp (Lőrinc)
Pull request description:
`UndoWriteToDisk` and `WriteBlockToDisk` were delegating a subset of their functionality to single-use methods that didn't optimally capture a meaningful chunk of the algorithm, resulting in calculating things twice (serialized size, header size).
This change inlines the awkward methods (asserting that all previous behavior was retained), and in separate commits makes the usages less confusing.
Besides making the methods slightly more intuitive, the refactorings reduce duplicate calculations as well.
The speed difference is insignificant for now (~0.5% for the new `SaveBlockToDiskBench`), but are a cleanup for follow-ups such as bitcoin/bitcoin#31539
ACKs for top commit:
ryanofsky:
Code review ACK 223081e. Since last review, "Save" was renamed to "Write", uint32_t references were dropped, some log statements and comments were improved as suggested, and a lot of tweaks made to commits and commit messages which should make this easier to review.
hodlinator:
ACK 223081e
TheCharlatan:
ACK 223081e
andrewtoth:
ACK 223081e
Tree-SHA512: 951bc8ad3504c510988afd95c561e3e259c6212bd14f6536fe56e8eb5bf5c35c32a368bbdb1d5aea1acc473d7e5bd9cdcde02008a148b05af1f955e413062d5cUndoWriteToDisk and WriteBlockToDisk to reduce serialization callsFile tree
20 files changed
+179
-204
lines changed- src
- bench
- index
- node
- rpc
- test
- util
20 files changed
+179
-204
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
| 191 | + | |
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | | - | |
| 259 | + | |
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | | - | |
| 259 | + | |
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
| 290 | + | |
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
| |||
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
418 | | - | |
| 418 | + | |
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1587 | 1587 | | |
1588 | 1588 | | |
1589 | 1589 | | |
1590 | | - | |
| 1590 | + | |
1591 | 1591 | | |
1592 | 1592 | | |
1593 | 1593 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2268 | 2268 | | |
2269 | 2269 | | |
2270 | 2270 | | |
2271 | | - | |
| 2271 | + | |
2272 | 2272 | | |
2273 | 2273 | | |
2274 | 2274 | | |
| |||
2282 | 2282 | | |
2283 | 2283 | | |
2284 | 2284 | | |
2285 | | - | |
| 2285 | + | |
2286 | 2286 | | |
2287 | 2287 | | |
2288 | 2288 | | |
| |||
4096 | 4096 | | |
4097 | 4097 | | |
4098 | 4098 | | |
4099 | | - | |
| 4099 | + | |
4100 | 4100 | | |
4101 | 4101 | | |
4102 | 4102 | | |
| |||
5599 | 5599 | | |
5600 | 5600 | | |
5601 | 5601 | | |
5602 | | - | |
| 5602 | + | |
5603 | 5603 | | |
5604 | 5604 | | |
5605 | 5605 | | |
| |||
0 commit comments