Commit e32bc7f
committed
Merge bitcoin#35025: refactor: use
13c8df4 refactor: replace `DataStream` with `SpanReader` in block deserialization tests (Lőrinc)
2529f25 refactor: use `SpanReader` in `PrevectorDeserialize` (Lőrinc)
b8eb6c2 refactor: use `SpanReader` in `TestBlockAndIndex` (Lőrinc)
61d678a refactor: use `DataStream::clear` in `::read` and `::ignore` (Lőrinc)
Pull request description:
### Problem
Block deserialization benches still read immutable fixture bytes through `DataStream`, which keeps around mutable stream semantics and old compaction-oriented setup that these call sites do not need anymore.
### Fix
We first remove the stale `Rewind()` parameter and failure path, which reduces rewinding to a simple reset of the read position that `clear()` can reuse.
We then route fully consumed `read()` and `ignore()` paths through `clear()`, remove the leftover compaction references and dummy-byte workaround, and finally switch the block deserialization benchmark readers to `SpanReader`.
`DeserializeBlockTest` can then deserialize directly from the fixture bytes without an untimed setup phase, while `CheckBlockTest` still keeps setup only to rebuild a fresh `CBlock` before the timed `CheckBlock()` call.
### Context
This follows the same direction as bitcoin#34483 and is a follow-up to bitcoin#34208.
The modified benchmarks retain their previous timing.
### Benchmarks
The affected benchmarks speeds don't seem to be affected by the changes.
<details><summary>Before & After</summary>
> Before:
```bash
| ns/op | op/s | err% | total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
| 37,591,891.96 | 26.60 | 1.0% | 11.07 | `BlockToJsonVerboseWrite`
| 155,664.09 | 6,424.09 | 0.1% | 10.99 | `BlockToJsonVerbosity1`
| 28,620,345.39 | 34.94 | 0.1% | 10.99 | `BlockToJsonVerbosity2`
| 28,637,604.74 | 34.92 | 0.1% | 11.01 | `BlockToJsonVerbosity3`
| ns/block | block/s | err% | total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
| 530,167.00 | 1,886.20 | 4.7% | 0.01 | `CheckBlockTest`
| 1,439,417.00 | 694.73 | 0.7% | 0.02 | `DeserializeBlockTest`
| ns/op | op/s | err% | total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
| 269.95 | 3,704,375.43 | 0.4% | 11.01 | `PrevectorDeserializeNontrivial`
| 14.90 | 67,114,436.52 | 0.0% | 10.88 | `PrevectorDeserializeTrivial`
```
> After:
```bash
| ns/op | op/s | err% | total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
| 37,114,824.07 | 26.94 | 1.8% | 10.89 | `BlockToJsonVerboseWrite`
| 154,881.99 | 6,456.53 | 0.2% | 10.99 | `BlockToJsonVerbosity1`
| 28,546,697.37 | 35.03 | 0.2% | 10.98 | `BlockToJsonVerbosity2`
| 28,547,328.27 | 35.03 | 0.3% | 11.02 | `BlockToJsonVerbosity3`
| ns/block | block/s | err% | total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
| 522,750.00 | 1,912.96 | 4.7% | 0.01 | `CheckBlockTest`
| 1,404,510.54 | 711.99 | 0.1% | 11.00 | `DeserializeBlockTest`
| ns/op | op/s | err% | total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
| 273.52 | 3,655,991.66 | 0.4% | 11.00 | `PrevectorDeserializeNontrivial`
| 14.31 | 69,863,193.52 | 1.4% | 11.03 | `PrevectorDeserializeTrivial`
```
</details>
ACKs for top commit:
maflcko:
review ACK 13c8df4 🐠
sedited:
Re-ACK 13c8df4
Tree-SHA512: b469874908c694b6b7f45e686519bdce0c0f4da2ca56b3f7f9897c7f27bb19a787f9821466995f15414343d508f15616b24b7fd8f0fa389ade8698c8f190b669SpanReader in deserialization benchmarks4 files changed
Lines changed: 21 additions & 51 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | 7 | | |
10 | 8 | | |
11 | 9 | | |
12 | | - | |
13 | | - | |
14 | 10 | | |
15 | | - | |
16 | 11 | | |
17 | 12 | | |
18 | 13 | | |
19 | 14 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | 15 | | |
24 | 16 | | |
25 | 17 | | |
26 | 18 | | |
27 | 19 | | |
28 | 20 | | |
29 | 21 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
34 | 28 | | |
35 | 29 | | |
36 | 30 | | |
37 | 31 | | |
38 | | - | |
39 | | - | |
| 32 | + | |
| 33 | + | |
40 | 34 | | |
41 | 35 | | |
42 | 36 | | |
43 | 37 | | |
44 | 38 | | |
45 | | - | |
46 | | - | |
| 39 | + | |
| 40 | + | |
47 | 41 | | |
48 | 42 | | |
49 | 43 | | |
50 | | - | |
| 44 | + | |
51 | 45 | | |
52 | 46 | | |
53 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
77 | | - | |
| 76 | + | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
84 | | - | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 34 | + | |
38 | 35 | | |
39 | 36 | | |
40 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | 209 | | |
231 | 210 | | |
232 | 211 | | |
| |||
243 | 222 | | |
244 | 223 | | |
245 | 224 | | |
246 | | - | |
247 | | - | |
| 225 | + | |
| 226 | + | |
248 | 227 | | |
249 | 228 | | |
250 | 229 | | |
| |||
258 | 237 | | |
259 | 238 | | |
260 | 239 | | |
261 | | - | |
262 | | - | |
| 240 | + | |
| 241 | + | |
263 | 242 | | |
264 | 243 | | |
265 | 244 | | |
| |||
0 commit comments