Skip to content

feat: Implement fast startup + lazy and cached loading for WebAssembly components#235

Merged
Mossaka merged 6 commits into
microsoft:mainfrom
Mossaka:mossaka/perf
Aug 27, 2025
Merged

feat: Implement fast startup + lazy and cached loading for WebAssembly components#235
Mossaka merged 6 commits into
microsoft:mainfrom
Mossaka:mossaka/perf

Conversation

@Mossaka

@Mossaka Mossaka commented Aug 25, 2025

Copy link
Copy Markdown
Contributor
  • feat: Implement unloaded lifecycle manager and background component loading
  • feat: add component metadata persistence

Close #204

@Mossaka Mossaka requested a review from Copilot August 25, 2025 21:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements fast startup and lazy loading for WebAssembly components by introducing an unloaded lifecycle manager, component metadata persistence, and background component loading with notification capabilities.

  • Creates unloaded lifecycle manager for instant startup without component compilation
  • Adds metadata caching system with validation stamps to avoid recompilation
  • Implements background component loading with bounded parallelism and client notifications

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/main.rs Adds peer storage, background loading coordination, and startup messaging updates
crates/wassette/src/lib.rs Core implementation of unloaded manager, metadata persistence, and optimized loading
crates/wassette/Cargo.toml Adds dependencies for CPU detection and SHA256 hashing
crates/component2json/src/lib.rs Makes FunctionIdentifier serializable for metadata persistence
crates/component2json/Cargo.toml Adds serde derive feature for serialization support

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/main.rs
Comment thread src/main.rs

// Try to load from precompiled cache first
if precompiled_path.exists() {
match unsafe { Component::deserialize_file(&self.engine, &precompiled_path) } {

Copilot AI Aug 25, 2025

Copy link

Choose a reason for hiding this comment

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

Using unsafe for component deserialization introduces potential security risks. Ensure the precompiled files are from trusted sources and consider adding integrity verification before deserialization.

Copilot uses AI. Check for mistakes.
Comment thread crates/wassette/src/lib.rs
…oading

Signed-off-by: Jiaxiao Zhou <duibao55328@gmail.com>
- Added ComponentMetadata structure with tool schemas, function identifiers,
  normalized tool names, and validation stamps
  - Implemented ValidationStamp with file size, modification time, and optional
  SHA256 hash for detecting changes
  - Added methods to save/load component metadata to {component_id}.metadata.json
   files
- Implemented .cwasm precompiled component files using
  engine.precompile_component()
  - Added load_component_optimized() method that tries precompiled cache first,
  falls back to compilation
  - Components are now saved as precompiled artifacts for faster subsequent loads
  - Used unsafe { Component::deserialize_file() } for loading precompiled
  components
- Added (commented) Wasmtime's built-in compilation cache configuration
  - This would provide additional caching across process restarts
- Implemented populate_registry_from_metadata() to quickly populate tool
  registry from cached metadata without compilation
  - Tools are registered immediately from metadata during startup phase
  - Components are loaded in memory later during background phase

Signed-off-by: Jiaxiao Zhou <duibao55328@gmail.com>
Signed-off-by: Jiaxiao Zhou <duibao55328@gmail.com>
…on tests

Signed-off-by: Jiaxiao Zhou <duibao55328@gmail.com>
Signed-off-by: Jiaxiao Zhou <duibao55328@gmail.com>
@Mossaka Mossaka merged commit bdbbd93 into microsoft:main Aug 27, 2025
9 checks passed
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.

Design proposal: Fast startup + lazy and cached loading

2 participants