feat: add a cache of compiled Wasm modules #4869
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.40) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 302 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.342
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #4869"
general
weight: 0.35
markmandel
What type of PR is this?
/kind feature
What this PR does / Why we need it:
Adds
pkg/util/wasm, a fixed size, least recently used cache of compiled Wasm (Extism) modules, for Wasm allocation actions (#4151).An allocation can name a Wasm module by URL. Downloading and compiling it on every allocation would be far too slow, so the allocator will keep compiled modules in this cache:
Callsets the policy'sconfigon its instance, so policies that share a module can use different config.singleflight), and different modules load in parallel, so a slow or unreachable URL only holds up calls that use that module.Callchecks its context before each attempt, so it does not run a plugin for a caller that has given up, or keep reloading a module that is evicted each time (possible when the cache is much smaller than the number of modules in use).Nothing uses the cache yet. The allocator will in a later PR, with a flag and Helm setting for the cache size.
github.com/tetratelabs/wazeroandgolang.org/x/syncmove to direct dependencies. Both were already vendored, sovendor/only gainsgolang.org/x/sync/singleflight.Which issue(s) this PR fixes:
Work on #4151
Did you use AI tools in preparing this PR?:
Y
Special notes for your reviewer:
Have a look at the timeouts for fetch and call. I think they are fine, but would like a second opinion.
I don't think we'll use this for FleetAutoscaling, as there is a natural 1:1 relationship between a FleetAutoscaler and it's wasm modules, which makes that much simpler.