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

[WGSL] Clean up AST nodes created during compilation #14349

Conversation

tadeuzagallo
Copy link
Member

@tadeuzagallo tadeuzagallo commented May 25, 2023

8f03835

[WGSL] Clean up AST nodes created during compilation
https://bugs.webkit.org/show_bug.cgi?id=257328
rdar://109833858

Reviewed by Mike Wyrzykowski.

We allocate new nodes during compilation, and since we can compile the
same module multiple times, that could lead to unbounded memory growth.
In order to fix that, we save the state of the allocator before we start
a new compilation and erase all objects allocate after that point once
we are done compiling. That is safe since we already revert all AST
modifications in a similar manner.

* Source/WebGPU/WGSL/AST/ASTBuilder.cpp:
(WGSL::AST::Builder::saveCurrentState):
(WGSL::AST::Builder::restore):
* Source/WebGPU/WGSL/AST/ASTBuilder.h:
* Source/WebGPU/WGSL/WGSL.cpp:
(WGSL::prepareImpl):
* Source/WebGPU/WGSL/WGSLShaderModule.h:
(WGSL::ShaderModule::Compilation::Compilation):
(WGSL::ShaderModule::Compilation::~Compilation):

Canonical link: https://commits.webkit.org/264571@main

edc32f8

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ›  gtk
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  tv-sim
❌ πŸ›  πŸ§ͺ merge βœ… πŸ›  watch
βœ… πŸ›  watch-sim

@tadeuzagallo tadeuzagallo self-assigned this May 25, 2023
@tadeuzagallo tadeuzagallo added the WebGPU For bugs in WebGPU label May 25, 2023
@tadeuzagallo tadeuzagallo added the merge-queue Applied to send a pull request to merge-queue label May 26, 2023
@webkit-commit-queue webkit-commit-queue force-pushed the eng/WGSL-Clean-up-AST-nodes-created-during-compilation branch from edc32f8 to 05675b4 Compare May 26, 2023 09:02
https://bugs.webkit.org/show_bug.cgi?id=257328
rdar://109833858

Reviewed by Mike Wyrzykowski.

We allocate new nodes during compilation, and since we can compile the
same module multiple times, that could lead to unbounded memory growth.
In order to fix that, we save the state of the allocator before we start
a new compilation and erase all objects allocate after that point once
we are done compiling. That is safe since we already revert all AST
modifications in a similar manner.

* Source/WebGPU/WGSL/AST/ASTBuilder.cpp:
(WGSL::AST::Builder::saveCurrentState):
(WGSL::AST::Builder::restore):
* Source/WebGPU/WGSL/AST/ASTBuilder.h:
* Source/WebGPU/WGSL/WGSL.cpp:
(WGSL::prepareImpl):
* Source/WebGPU/WGSL/WGSLShaderModule.h:
(WGSL::ShaderModule::Compilation::Compilation):
(WGSL::ShaderModule::Compilation::~Compilation):

Canonical link: https://commits.webkit.org/264571@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/WGSL-Clean-up-AST-nodes-created-during-compilation branch from 05675b4 to 8f03835 Compare May 26, 2023 09:05
@webkit-commit-queue
Copy link
Collaborator

Committed 264571@main (8f03835): https://commits.webkit.org/264571@main

Reviewed commits have been landed. Closing PR #14349 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 8f03835 into WebKit:main May 26, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebGPU For bugs in WebGPU
Projects
None yet
4 participants