Skip to content

Module cache rebuild logic#5175

Open
graydon wants to merge 3 commits intostellar:masterfrom
graydon:module-cache-rebuild-logic
Open

Module cache rebuild logic#5175
graydon wants to merge 3 commits intostellar:masterfrom
graydon:module-cache-rebuild-logic

Conversation

@graydon
Copy link
Contributor

@graydon graydon commented Mar 12, 2026

This does a little simplification on the arithmetic we were doing to track thresholds of module cache rebuilding, as well as clarifying when we're measuring input vs. output values in the cost model. Also it moves the module cache tests to a separate file, as part of my long term dream to split InvokeHostFunctionTests.cpp into multiple files.

One disappointing part about this is that the tweak above reveals that the ApplyState state-invariant-checking that @SirTyson put in back in #4819 was actually slightly incorrect: the finishPendingCompilation method does actually write to ApplyState when it's in READY_TO_APPLY (it did back then too, it just didn't happen to occur in tests before). I can't think of any really great way to avoid this (the whole point is to defer the implied variable-update/stall until the last moment before we'll need it) besides I guess we could like add in another state? I don't know if that would win much, but I'd be willing to if that's your preference @SirTyson ?

Copilot AI review requested due to automatic review settings March 12, 2026 01:50
@graydon graydon requested a review from SirTyson March 12, 2026 01:53
Copy link
Contributor

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 encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

}
currCompiledWasmBytes += mModuleCache->get_wasm_bytes_input(v);
}
if (currCompiledWasmBytes > (2 * lastCompiledWasmBytes))
Copy link
Contributor

@jayz22 jayz22 Mar 12, 2026

Choose a reason for hiding this comment

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

I think the mModuleCacheRebuildBytes only counts a Wasm contract bytes once, whereas currCompiledWasmBytes counts the total bytes across all protocols (which means the the same Wasm contract is counted multiple times).
So currCompiledWasmBytes will always be larger than 2 * lastCompiledWasmBytes since there are three active protocols (23,24,25)?

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.

3 participants