Commit 3337731
committed
Improve performance of writing markers
This commit improves the performance of samply-markers
when enabled, based on benchmarks of the Fibonacci example
increased to n = 30 and measured with hyperfine.
The Fibonacci example at n = 30 makes 2,692,536 recursive
calls, emitting the same number of markers. This provides
a great stress test for marker emission overhead.
The configurations are as follows:
- disabled: samply-markers disabled
- enabled-baseline: samply-markers enabled before any performance improvements
- buffered-writes: adds the buffered writes improvement
- itoa-buffers: adds the itoa improvement on top of buffered writes
Linux results:
Benchmark 1: ./fib30-disabled
Time (mean ± σ): 128.2 ms ± 0.6 ms [User: 127.2 ms, System: 0.9 ms]
Range (min … max): 127.1 ms … 129.6 ms 23 runs
Benchmark 2: ./fib30-enabled-baseline
Time (mean ± σ): 3.144 s ± 0.009 s [User: 0.924 s, System: 2.220 s]
Range (min … max): 3.134 s … 3.161 s 10 runs
Benchmark 3: ./fib30-enabled-buffered-writes
Time (mean ± σ): 522.9 ms ± 1.1 ms [User: 478.9 ms, System: 43.7 ms]
Range (min … max): 520.2 ms … 524.1 ms 10 runs
Benchmark 4: ./fib30-enabled-itoa-buffers
Time (mean ± σ): 423.1 ms ± 1.8 ms [User: 377.8 ms, System: 45.1 ms]
Range (min … max): 419.6 ms … 426.3 ms 10 runs
Summary
./fib30-disabled ran
3.30 ± 0.02 times faster than ./fib30-enabled-itoa-buffers
4.08 ± 0.02 times faster than ./fib30-enabled-buffered-writes
24.53 ± 0.14 times faster than ./fib30-enabled-baseline
macOS results:
Benchmark 1: ./fib30-disabled
Time (mean ± σ): 90.7 ms ± 0.4 ms [User: 89.4 ms, System: 0.9 ms]
Range (min … max): 90.0 ms … 91.6 ms 31 runs
Benchmark 2: ./fib30-enabled-baseline
Time (mean ± σ): 4.384 s ± 0.053 s [User: 0.578 s, System: 3.783 s]
Range (min … max): 4.295 s … 4.495 s 10 runs
Benchmark 3: ./fib30-enabled-buffered-writes
Time (mean ± σ): 257.4 ms ± 1.8 ms [User: 237.6 ms, System: 16.9 ms]
Range (min … max): 255.1 ms … 261.8 ms 11 runs
Benchmark 4: ./fib30-enabled-itoa-buffers
Time (mean ± σ): 187.6 ms ± 1.1 ms [User: 169.9 ms, System: 16.1 ms]
Range (min … max): 186.3 ms … 190.1 ms 15 runs
Summary
./fib30-disabled ran
2.07 ± 0.01 times faster than ./fib30-enabled-itoa-buffers
2.84 ± 0.02 times faster than ./fib30-enabled-buffered-writes
48.32 ± 0.62 times faster than ./fib30-enabled-baseline
Profiles:
Ubuntu:
* fib30-disabled: https://share.firefox.dev/48id64U
* fib30-enabled-baseline: https://share.firefox.dev/47K8Taf
* fib30-enabled-buffered-writes: https://share.firefox.dev/4oK5Uog
* fib30-enabled-itoa-buffers: https://share.firefox.dev/47ZtGVQ
macOS:
* fib30-disabled: https://share.firefox.dev/3LMmaX2
* fib30-enabled-baseline: https://share.firefox.dev/49TPODF
* fib30-enabled-buffered-writes: https://share.firefox.dev/4oFo1LP
* fib30-enabled-itoa-buffers: https://share.firefox.dev/3K6rLqG
Overall:
- Using buffered writes dramatically reduces overhead.
- Using itoa provides an additional ~19% improvement on Linux and ~27% on macOS.1 parent 4e7944b commit 3337731
File tree
5 files changed
+421
-191
lines changed- samply-markers
- src
- marker
- provider
- tests
5 files changed
+421
-191
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | | - | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | | - | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | | - | |
44 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
45 | 46 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 47 | + | |
| 48 | + | |
51 | 49 | | |
52 | 50 | | |
53 | 51 | | |
| |||
83 | 81 | | |
84 | 82 | | |
85 | 83 | | |
86 | | - | |
| 84 | + | |
87 | 85 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | 86 | | |
94 | | - | |
95 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
96 | 90 | | |
97 | 91 | | |
98 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
26 | 26 | | |
27 | 27 | | |
28 | 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 | + | |
29 | 56 | | |
30 | 57 | | |
31 | 58 | | |
| |||
35 | 62 | | |
36 | 63 | | |
37 | 64 | | |
38 | | - | |
39 | | - | |
| 65 | + | |
| 66 | + | |
40 | 67 | | |
41 | 68 | | |
42 | 69 | | |
| |||
47 | 74 | | |
48 | 75 | | |
49 | 76 | | |
| 77 | + | |
50 | 78 | | |
51 | 79 | | |
52 | 80 | | |
53 | | - | |
| 81 | + | |
| 82 | + | |
54 | 83 | | |
55 | 84 | | |
56 | 85 | | |
| |||
94 | 123 | | |
95 | 124 | | |
96 | 125 | | |
| 126 | + | |
97 | 127 | | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
106 | 143 | | |
107 | 144 | | |
108 | 145 | | |
| |||
111 | 148 | | |
112 | 149 | | |
113 | 150 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | 151 | | |
125 | 152 | | |
126 | 153 | | |
| |||
159 | 186 | | |
160 | 187 | | |
161 | 188 | | |
162 | | - | |
| 189 | + | |
163 | 190 | | |
164 | 191 | | |
165 | 192 | | |
| |||
216 | 243 | | |
217 | 244 | | |
218 | 245 | | |
219 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
220 | 278 | | |
0 commit comments