Commit 80bbe09
authored
Protect against HashMap rehash spikes in UnresolvedSamples (#737)
While adding support for in-kernel unwinding with sample rates as high
as 4KHz, sample dropping became an issue. Looking closer using a `perf
record` of compiler running on 16 CPU, 4KHz samples, rehashing was
taking over 260ms in the worst case (see "Stack Chart" and highlighting
rehash): https://share.firefox.dev/3Y32wsT
This changes so that UnresolvedStacks uses a BTreeMap for the interning
storage, which has a much more bounded O(log n) worst case insertion. An
LRU hash map serves on top as an O(1) fast path.
The new implementation is roughly on par and perhaps slightly faster,
and processing time spikes are almost gone:
https://share.firefox.dev/4pMM9wy
Footnote, the `stacks` array itself also suffers from O(n) realloc
behavior, but that doesn't seem to be problematic *yet*, so I'll leave
this for when it's found to be a problem in the future.4 files changed
+82
-16
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 | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
| 5 | + | |
| 6 | + | |
4 | 7 | | |
5 | 8 | | |
6 | 9 | | |
| |||
154 | 157 | | |
155 | 158 | | |
156 | 159 | | |
157 | | - | |
| 160 | + | |
158 | 161 | | |
159 | 162 | | |
160 | 163 | | |
161 | 164 | | |
162 | 165 | | |
163 | 166 | | |
164 | 167 | | |
165 | | - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
166 | 173 | | |
167 | 174 | | |
168 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
169 | 198 | | |
170 | 199 | | |
171 | 200 | | |
| |||
182 | 211 | | |
183 | 212 | | |
184 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
185 | 219 | | |
186 | 220 | | |
187 | 221 | | |
188 | 222 | | |
189 | 223 | | |
| 224 | + | |
190 | 225 | | |
191 | 226 | | |
192 | 227 | | |
| |||
198 | 233 | | |
199 | 234 | | |
200 | 235 | | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
212 | 240 | | |
213 | 241 | | |
214 | 242 | | |
| |||
0 commit comments