Commit 689e847
committed
Auto merge of rust-lang#83458 - saethlin:improve-vec-benches, r=dtolnay
Clean up Vec's benchmarks
The Vec benchmarks need a lot of love. I sort of noticed this in rust-lang#83357 but the overall situation is much less awesome than I thought at the time. The first commit just removes a lot of asserts and does a touch of other cleanup.
A number of these benchmarks are poorly-named. For example, `bench_map_fast` is not in fact fast, `bench_rev_1` and `bench_rev_2` are vague, `bench_in_place_zip_iter_mut` doesn't call `zip`, `bench_in_place*` don't do anything in-place... Should I fix these, or is there tooling that depend on the names not changing?
I've also noticed that `bench_rev_1` and `bench_rev_2` are remarkably fragile. It looks like poking other code in `Vec` can cause the codegen of this benchmark to switch to a version that has almost exactly half its current throughput and I have absolutely no idea why.
Here's the fast version:
```asm
0.69 │110: movdqu -0x20(%rbx,%rdx,4),%xmm0
1.76 │ movdqu -0x10(%rbx,%rdx,4),%xmm1
0.71 │ pshufd $0x1b,%xmm1,%xmm1
0.60 │ pshufd $0x1b,%xmm0,%xmm0
3.68 │ movdqu %xmm1,-0x30(%rcx)
14.36 │ movdqu %xmm0,-0x20(%rcx)
13.88 │ movdqu -0x40(%rbx,%rdx,4),%xmm0
6.64 │ movdqu -0x30(%rbx,%rdx,4),%xmm1
0.76 │ pshufd $0x1b,%xmm1,%xmm1
0.77 │ pshufd $0x1b,%xmm0,%xmm0
1.87 │ movdqu %xmm1,-0x10(%rcx)
13.01 │ movdqu %xmm0,(%rcx)
38.81 │ add $0x40,%rcx
0.92 │ add $0xfffffffffffffff0,%rdx
1.22 │ ↑ jne 110
```
And the slow one:
```asm
0.42 │9a880: movdqa %xmm2,%xmm1
4.03 │9a884: movq -0x8(%rbx,%rsi,4),%xmm4
8.49 │9a88a: pshufd $0xe1,%xmm4,%xmm4
2.58 │9a88f: movq -0x10(%rbx,%rsi,4),%xmm5
7.02 │9a895: pshufd $0xe1,%xmm5,%xmm5
4.79 │9a89a: punpcklqdq %xmm5,%xmm4
5.77 │9a89e: movdqu %xmm4,-0x18(%rdx)
15.74 │9a8a3: movq -0x18(%rbx,%rsi,4),%xmm4
3.91 │9a8a9: pshufd $0xe1,%xmm4,%xmm4
5.04 │9a8ae: movq -0x20(%rbx,%rsi,4),%xmm5
5.29 │9a8b4: pshufd $0xe1,%xmm5,%xmm5
4.60 │9a8b9: punpcklqdq %xmm5,%xmm4
9.81 │9a8bd: movdqu %xmm4,-0x8(%rdx)
11.05 │9a8c2: paddq %xmm3,%xmm0
0.86 │9a8c6: paddq %xmm3,%xmm2
5.89 │9a8ca: add $0x20,%rdx
0.12 │9a8ce: add $0xfffffffffffffff8,%rsi
1.16 │9a8d2: add $0x2,%rdi
2.96 │9a8d6: → jne 9a880 <<alloc::vec::Vec<T,A> as core::iter::traits::collect::Extend<&T>>::extend+0xd0>
```1 file changed
+25
-68
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
| 7 | + | |
13 | 8 | | |
14 | 9 | | |
15 | 10 | | |
16 | 11 | | |
17 | 12 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 13 | + | |
24 | 14 | | |
25 | 15 | | |
26 | 16 | | |
| |||
46 | 36 | | |
47 | 37 | | |
48 | 38 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
| 39 | + | |
55 | 40 | | |
56 | 41 | | |
57 | 42 | | |
| |||
77 | 62 | | |
78 | 63 | | |
79 | 64 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 65 | + | |
86 | 66 | | |
87 | 67 | | |
88 | 68 | | |
| |||
110 | 90 | | |
111 | 91 | | |
112 | 92 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 93 | + | |
119 | 94 | | |
120 | 95 | | |
121 | 96 | | |
| |||
144 | 119 | | |
145 | 120 | | |
146 | 121 | | |
147 | | - | |
148 | | - | |
149 | | - | |
| 122 | + | |
150 | 123 | | |
151 | 124 | | |
152 | 125 | | |
| |||
180 | 153 | | |
181 | 154 | | |
182 | 155 | | |
183 | | - | |
184 | | - | |
185 | 156 | | |
186 | 157 | | |
187 | 158 | | |
| |||
230 | 201 | | |
231 | 202 | | |
232 | 203 | | |
233 | | - | |
234 | | - | |
235 | 204 | | |
236 | 205 | | |
237 | 206 | | |
| |||
290 | 259 | | |
291 | 260 | | |
292 | 261 | | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
| 262 | + | |
299 | 263 | | |
300 | 264 | | |
301 | 265 | | |
| |||
329 | 293 | | |
330 | 294 | | |
331 | 295 | | |
332 | | - | |
333 | | - | |
| 296 | + | |
334 | 297 | | |
335 | 298 | | |
336 | 299 | | |
| |||
463 | 426 | | |
464 | 427 | | |
465 | 428 | | |
466 | | - | |
| 429 | + | |
467 | 430 | | |
468 | 431 | | |
469 | | - | |
470 | | - | |
| 432 | + | |
471 | 433 | | |
472 | 434 | | |
473 | 435 | | |
| |||
527 | 489 | | |
528 | 490 | | |
529 | 491 | | |
530 | | - | |
531 | 492 | | |
532 | 493 | | |
533 | 494 | | |
| |||
614 | 575 | | |
615 | 576 | | |
616 | 577 | | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | 578 | | |
635 | 579 | | |
636 | 580 | | |
| |||
669 | 613 | | |
670 | 614 | | |
671 | 615 | | |
672 | | - | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
673 | 621 | | |
674 | 622 | | |
675 | 623 | | |
| |||
685 | 633 | | |
686 | 634 | | |
687 | 635 | | |
688 | | - | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
689 | 646 | | |
690 | 647 | | |
691 | 648 | | |
| |||
0 commit comments