Skip to content

Merge query cache and query state#156632

Draft
zetanumbers wants to merge 2 commits into
rust-lang:mainfrom
zetanumbers:query_cache_entry
Draft

Merge query cache and query state#156632
zetanumbers wants to merge 2 commits into
rust-lang:mainfrom
zetanumbers:query_cache_entry

Conversation

@zetanumbers
Copy link
Copy Markdown
Contributor

@zetanumbers zetanumbers commented May 16, 2026

So basically we have query cache and query state separate "hash" tables. Cache tracks completed queries while state tracks unfinished queries. Thus we are required to a double check lookup while updating one of them like in try_execute_query and we do multiple hash table lookups while executing a query since cache/state entry might have moved due to rehashing. This PR merges query cache with query state and stores query cache entries in an arena for its stable memory location.

However my manually written slop code currently breaks query cycle detection, but I know how to fix it.

More details in #t-compiler/query-system > Merging query cache and query state

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 16, 2026
@zetanumbers
Copy link
Copy Markdown
Contributor Author

And there're the benchmark results for 4 threads on my MacBook Pro M1 Pro:

BenchmarkBeforeAfter
TimeTime%
🟣 regex:check0.2070s0.2031s💚 -1.90%
🟣 regex:check:initial0.2437s0.2430s -0.28%
🟣 regex:check:unchanged0.1195s0.1192s -0.25%
🟣 syn:check0.3599s0.3546s💚 -1.48%
🟣 syn:check:initial0.4273s0.4204s💚 -1.63%
🟣 syn:check:unchanged0.2503s0.2473s💚 -1.21%
🟣 clap:check0.3343s0.3274s💚 -2.07%
🟣 clap:check:initial0.3885s0.3804s💚 -2.10%
🟣 clap:check:unchanged0.1589s0.1582s -0.46%
🟣 hyper:check0.0757s0.0731s💚 -3.42%
🟣 hyper:check:initial0.0913s0.0882s💚 -3.44%
🟣 hyper:check:unchanged0.0545s0.0548s 0.53%
Total2.7109s2.6694s💚 -1.53%
Summary1.0000s0.9852s💚 -1.48%

@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

The job x86_64-gnu-miri failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants