Skip to content
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

[naga] Improve algorithm for Module compaction. #4662

Merged
merged 1 commit into from
Nov 14, 2023

Conversation

jimblandy
Copy link
Member

@jimblandy jimblandy commented Nov 10, 2023

Identify reachable function expressions, constant expressions, and types using a single pass over each arena, taking advantage of the fact that expressions and types may only refer to other entries that precede them within their arena. Only walking the statement tree still requires a worklist/recursion.

In addition to presumably being faster, this change slightly reduces the number of non-comment lines of code in src/compact.

Closes #4509.

Checklist

  • Run cargo clippy.
  • Run cargo clippy --target wasm32-unknown-unknown if applicable.
  • Add change to CHANGELOG.md. See simple instructions inside file.

@jimblandy jimblandy requested a review from a team as a code owner November 10, 2023 00:54
Identify reachable function expressions, constant expressions, and
types using a single pass over each arena, taking advantage of the
fact that expressions and types may only refer to other entries that
precede them within their arena. Only walking the statement tree still
requires a worklist/recursion.

In addition to presumably being faster, this change slightly reduces
the number of non-comment lines of code in `src/compact`.
@jimblandy jimblandy force-pushed the naga-stackless-compact branch from ea35340 to 0b4be22 Compare November 10, 2023 00:56
Copy link
Member

@teoxoy teoxoy left a comment

Choose a reason for hiding this comment

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

Good stuff!

@teoxoy
Copy link
Member

teoxoy commented Nov 10, 2023

I noticed the prior PR changed the IR tests but this one doesn't.
Was this expected? I haven't looked too deeply what the differences between the code are.

@jimblandy
Copy link
Member Author

I noticed the prior PR changed the IR tests but this one doesn't. Was this expected? I haven't looked too deeply what the differences between the code are.

Yes, this is expected: this PR only improves the algorithm, but it doesn't yet apply it in any new places. The prior PR introduced a new compactor specific to the WGSL front end, and added uses of it.

@jimblandy jimblandy merged commit 734e246 into gfx-rs:trunk Nov 14, 2023
27 checks passed
@jimblandy jimblandy deleted the naga-stackless-compact branch December 13, 2023 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compaction could be faster
2 participants