This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit b585189
committed
Auto merge of rust-lang#137196 - saethlin:stabilize-query-cache-size, r=<try>
Stabilize query cache size by fixing encoding order of some query results
r? ghost
Our query cache sizes fluctuate randomly in perf reports because of this combination of effects:
`Instance` and `ParamEnv` (as well as some other things, but those are the types that matter) have `Hash` impls that hash pointers, so when we encode our query caches by iterating over the `FxHashMap` that implements the cache, we get a random iteration order.
The shorthand encoding system that `Ty` uses causes us to varint-encode the current encoding offset. This turns unstable encoding order into unstable encoded size.
There are quite a few ways this could be fixed:
* Make the `Hash` impl on `Interned` hash the contents instead of the pointer. This would involve adding `Hash` impls to a *lot* of types that do not have any.
* Teach the `Hash` impl on `Interned` about what the base address of the interner is, so that it can hash the offset into the arena. Each arena is actually duplicated N times because they are all thread-local, so I don't know that this is realistic.
* Sort the query results before we write them out. This is a pretty bad kludge IMO because we still have nondeterministic execution, we're just then doing extra nondet compute to paper over it.
* Change the query cache type for the affected queries to `IndexMap` (surely this has compile-time overhead right? And it'll probably be whack-a-mole going forward)
* Encode the shorthand offsets with a fixed-width encoding instead of varint. (surely this has file size overhead, but probably not much?)
I think the last two options have the most promise by far. I can implement the `IndexMap` change easily so I'm trying that first.File tree
5 files changed
+51
-4
lines changed- compiler
- rustc_middle/src/query
- rustc_query_system
- src/query
5 files changed
+51
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4435 | 4435 | | |
4436 | 4436 | | |
4437 | 4437 | | |
| 4438 | + | |
4438 | 4439 | | |
4439 | 4440 | | |
4440 | 4441 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
474 | | - | |
| 474 | + | |
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
0 commit comments