Skip to content

feat(plugin): implement WASM module instance pooling#10136

Draft
ankit98040 wants to merge 5 commits intoaquasecurity:mainfrom
ankit98040:feat/wasm-module-pooling
Draft

feat(plugin): implement WASM module instance pooling#10136
ankit98040 wants to merge 5 commits intoaquasecurity:mainfrom
ankit98040:feat/wasm-module-pooling

Conversation

@ankit98040
Copy link
Contributor

Description

This PR implements module instance pooling for WASM modules. Previously, WASM module analysis was serialized using a mutex because wazero module instances are not thread-safe. This change introduces a sync.Pool to manage a pool of wasmInstances, allowing concurrent execution of Analyze and PostScan methods. This directly addresses the TODO comment in pkg/module/module.go regarding performance improvements to "improve the Analyze performance by having module instance pool".

Key changes:

  • Refactored wasmModule to be a manager that holds a sync.Pool of instances.
  • Introduced wasmInstance struct to hold stateful module data (api.Module, memFS, exported functions).
  • Updated Analyze and PostScan to lease instances from the pool for the effective duration of the call.
  • Updated Close to properly close the wazero.Runtime and cleanup resources.

Related issues

  • Addresses "TODO: This is temporary solution and we could improve the Analyze performance by having module instance pool."

Related PRs

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works. (Verified that existing tests pass with the refactoring).
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@ankit98040 ankit98040 requested a review from knqyf263 as a code owner February 4, 2026 06:50
@ankit98040 ankit98040 force-pushed the feat/wasm-module-pooling branch from c1ec554 to 7a57e05 Compare February 4, 2026 06:52
@ankit98040 ankit98040 changed the title feat(module): implement WASM module instance pooling feat(plugin): implement WASM module instance pooling Feb 4, 2026
@knqyf263 knqyf263 marked this pull request as draft February 5, 2026 10:37
@nikpivkin
Copy link
Contributor

Hi @ankit98040 !

It looks like you have another identical PR open. Could you close one of them?

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.

2 participants