alexcrichton opened PR #14314 from alexcrichton:drop-some-caches to bytecodealliance:main:
This commit is intended to address the issue described in bytecodealliance/wasmtime-go#295 where an embedder upgraded from 47.0.x to 48.0.x and the sustained RSS of the application jumped by a significant margin (~20G). With a reproduction bisection shows that the cause of this jump is #13912.
Poking around a bit #13912 feel pretty surprising to be the cause here, but it ends up being the case that the
regalloc2::Contextstructures that are preserved are apparently quite large, especially for compiled Go functions. These contexts are preserved permanently in anEnginefor the entire lifetime of an application. This particular embedding had sort of pathological behavior here where an engine was created per-module, causing the per-engine caches to blow up in size significantly.This commit adds a hook to module/component compilation to clear out the list of internal caches once a module or component finishes to compile. The rough theory is that these caches help when compiling within a single module but don't have too too much overhead to recreate across modules. The end result though is that these aren't permanently preserved in an
Engineand instead there's at least some vector by which large caches are dropped.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease review the Bytecode Alliance's AI tool usage policy at
https://github.com/bytecodealliance/governance/blob/main/AI_TOOL_POLICY.mdPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton requested cfallin for a review on PR #14314.
alexcrichton requested wasmtime-compiler-reviewers for a review on PR #14314.
alexcrichton requested wasmtime-core-reviewers for a review on PR #14314.
github-actions[bot] added the label wasmtime:api on PR #14314.
github-actions[bot] added the label winch on PR #14314.
github-actions[bot] commented on PR #14314:
Subscribe to Label Action
cc @saulecabrera
<details>
This issue or pull request has been labeled: "wasmtime:api", "winch"Thus the following users have been cc'd because of the following labels:
- saulecabrera: winch
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
:thumbs_up: cfallin submitted PR review:
Thanks! I'm surprised that we had been holding this memory across all time; it's normal and natural that compilation of big modules will result in spiky memory usage and I would expect we'd release it back to the allocator/OS when done, so I'm glad we do so now!
cfallin added PR #14314 Drop cached compiler contexts between modules/components to the merge queue.
:check: cfallin merged PR #14314.
cfallin removed PR #14314 Drop cached compiler contexts between modules/components from the merge queue.
Last updated: Sep 20 2026 at 18:08 UTC