Skip to content

Rust: Cache tweaks #19246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2025
Merged

Rust: Cache tweaks #19246

merged 1 commit into from
Apr 10, 2025

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Apr 8, 2025

Using @aschackmull 's stage overlay script, I identified some unintended cases of predicates being recomputed, which this PR addresses, by making sure that more predicates are cached (in the same stage).

DCA shows a whopping 10% analysis time speedup, and we also reduce the DIL size as expected.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Apr 8, 2025
@hvitved hvitved marked this pull request as ready for review April 9, 2025 07:09
@Copilot Copilot AI review requested due to automatic review settings April 9, 2025 07:09
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

Files not reviewed (5)
  • rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll: Language not supported
  • rust/ql/lib/codeql/rust/elements/internal/AstNodeImpl.qll: Language not supported
  • rust/ql/lib/codeql/rust/elements/internal/VariableImpl.qll: Language not supported
  • rust/ql/lib/codeql/rust/internal/CachedStages.qll: Language not supported
  • rust/ql/lib/codeql/rust/internal/PathResolution.qll: Language not supported

@hvitved hvitved requested a review from paldepind April 9, 2025 07:54
Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DCA results look great.

I'm not familiar with the Cached::ref() pattern. Roughly what is going on here?

@hvitved
Copy link
Contributor Author

hvitved commented Apr 10, 2025

I'm not familiar with the Cached::ref() pattern. Roughly what is going on here?

Normally, in order to ensure that cached predicates are evaluated in the same stage, one puts them into the same cached module. However, when those predicates are located in different files, that is not possible, and even if they are, it sometimes breaks the logical order of the predicates.

Instead, one can add another cached module, with two dummy predicates ref and backref; predicates that then need to be cached together should all call the ref predicate, and all those predicate should be called from backref. Since both ref and backref are cached, they will belong to the same stage, and because of mutual dependencies so will the predicates that we actually wanted to belong to the same stage.

Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@hvitved hvitved merged commit 7ed8a85 into github:main Apr 10, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants