Optimize new solver unification table ops - #160801
Conversation
In `is_changed_arg` we do four variations on this (pseudocode-ish) expression: ``` !(probe_value(vid) == Unknown && find(vid) == vid) ``` The first sub-expression means "the var's value is unknown" and the second means "this var is a root". `probe_value` and `find` are both parent-chasing operations, i.e. they duplicate some of their work. We can instead use `try_probe_value` to do this more cheaply: ``` try_probe_value(vid) != Some(Unknown) ``` This has the identical meaning because `try_probe_value` means "get the var's value, but only if it's a root". (Strange but fortuitous!) There are four cases like this in `is_changed_arg`. Three of them (int/float/const vars) are very similar to each other. The ty var case has slightly different syntax but it's the same idea.
In this case we currently have something approximating this: ``` find(vid) != vid ``` which means "is this not a root var?" This commit changes it to basically this: ``` !try_probe_value(vid).is_some() ``` which is equivalent but doesn't require any parent chasing.
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Optimize new solver unification table ops
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (6faf9bb): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 2.3%, secondary 1.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary -0.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary -0.1%, secondary -0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 458.036s -> 459.953s (0.42%) |
The current code uses the
enacrate in sub-optimal ways. Improving this gives big speed wins for the new trait solver on some benchmarks. Details in individual commits.