5

Use dynamic dispatch for queries by Zoxc · Pull Request #108638 · rust-lang/rust...

 1 year ago
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.
neoserver,ios ssh client

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.

BenchmarkBeforeAfter
TimeTime%
purple_circleclap:check1.7055s1.6949s -0.62%
purple_circlehyper:check0.2547s0.2528s -0.73%
purple_circleregex:check0.9590s0.9553s -0.39%
purple_circlesyn:check1.5457s1.5440s -0.11%
purple_circlesyntex_syntax:check5.9092s5.9009s -0.14%
Total10.3741s10.3479s -0.25%
Summary1.0000s0.9960s -0.40%
BenchmarkBeforeAfter
TimeTime%
purple_circleclap:check:initial2.0605s2.0575s -0.15%
purple_circlehyper:check:initial0.3218s0.3216s -0.07%
purple_circleregex:check:initial1.1848s1.1839s -0.07%
purple_circlesyn:check:initial1.9409s1.9376s -0.17%
purple_circlesyntex_syntax:check:initial7.3105s7.2928s -0.24%
Total12.8185s12.7935s -0.20%
Summary1.0000s0.9986s -0.14%
BenchmarkBeforeAfter
TimeTime%
purple_circleclap:check:unchanged0.4606s0.4617s 0.24%
purple_circlehyper:check:unchanged0.1335s0.1336s 0.08%
purple_circleregex:check:unchanged0.3324s0.3346s 0.65%
purple_circlesyn:check:unchanged0.6268s0.6307s 0.64%
purple_circlesyntex_syntax:check:unchanged1.8248s1.8508sbroken_heart 1.43%
Total3.3779s3.4113s 0.99%
Summary1.0000s1.0061s 0.61%

It's based on #108167.

r? @cjgillot

jyn514 reacted with heart emoji

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK