Use dynamic dispatch for queries by Zoxc · Pull Request #108638 · rust-lang/rust...
source link: https://github.com/rust-lang/rust/pull/108638
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Conversation
Contributor
This replaces most concrete query values V
with MaybeUninit<[u8; { size_of::<V>() }]>
reducing the code instantiated by queries. The compile time of rustc_query_impl
is reduced by 27%. It is an alternative to #107937 which uses unstable const generics while this uses a EraseType
trait which maps query values to their erased variant.
This is achieved by introducing an Erased
type which does sanity check with cfg(debug_assertions)
. The query caches gets instantiated with these erased types leaving the code in rustc_query_system
unaware of them. rustc_query_system
is changed to use instances of QueryConfig
so that rustc_query_impl
can pass in DynamicConfig
which holds a pointer to a virtual table.
Benchmark | Before | After | |
Time | Time | % | |
clap:check | 1.7055s | 1.6949s | -0.62% |
hyper:check | 0.2547s | 0.2528s | -0.73% |
regex:check | 0.9590s | 0.9553s | -0.39% |
syn:check | 1.5457s | 1.5440s | -0.11% |
syntex_syntax:check | 5.9092s | 5.9009s | -0.14% |
Total | 10.3741s | 10.3479s | -0.25% |
Summary | 1.0000s | 0.9960s | -0.40% |
Benchmark | Before | After | |
Time | Time | % | |
clap:check:initial | 2.0605s | 2.0575s | -0.15% |
hyper:check:initial | 0.3218s | 0.3216s | -0.07% |
regex:check:initial | 1.1848s | 1.1839s | -0.07% |
syn:check:initial | 1.9409s | 1.9376s | -0.17% |
syntex_syntax:check:initial | 7.3105s | 7.2928s | -0.24% |
Total | 12.8185s | 12.7935s | -0.20% |
Summary | 1.0000s | 0.9986s | -0.14% |
Benchmark | Before | After | |
Time | Time | % | |
clap:check:unchanged | 0.4606s | 0.4617s | 0.24% |
hyper:check:unchanged | 0.1335s | 0.1336s | 0.08% |
regex:check:unchanged | 0.3324s | 0.3346s | 0.65% |
syn:check:unchanged | 0.6268s | 0.6307s | 0.64% |
syntex_syntax:check:unchanged | 1.8248s | 1.8508s | 1.43% |
Total | 3.3779s | 3.4113s | 0.99% |
Summary | 1.0000s | 1.0061s | 0.61% |
It's based on #108167.
r? @cjgillot
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK