Skip to content

Conversation

@bnjbvr
Copy link
Owner

@bnjbvr bnjbvr commented Apr 24, 2025

For the record: most of the code in the "feat: compile modules in parallel" commit has been "vibe" "coded". My experience of it was painful: it was super super slow, the agent generated incorrect code several times, that didn't compile, and it got stuck not managing to fix the compilation failures for a short cycle.

I'll probably rejigger the changes so they make more sense, but overall this is nice to compile the modules in parallel, even though it's not really a problem for release builds of the rust modules (it's more a problem for the debug builds where lots of lib code isn't stripped out).

@bnjbvr bnjbvr requested a review from Copilot April 25, 2025 08:00
Copy link

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.

Pull Request Overview

The purpose of this PR is to refactor the module linking and store usage to compile wasm modules in parallel, replacing the old GuestState with a new Apis type. Key changes include updating the API linking functions, modifying store creation and module iteration logic for parallel compilation, and updating admin/help command handling to use the new types.

  • Updating API link signatures across several files (sys.rs, sync_request.rs, log.rs, kv_store.rs)
  • Changing the Wasm module store type from GuestState to Apis and compiling modules in parallel using rayon
  • Adjusting admin and help command handling to work with the new module-store structure

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/wasm/apis/sys.rs Updated API linking signature to use Apis instead of GuestState
src/wasm/apis/sync_request.rs Updated API linking signature to use Apis
src/wasm/apis/mod.rs Removed GuestState and updated linking to use Apis
src/wasm/apis/log.rs Updated API linking signature to use Apis
src/wasm/apis/kv_store.rs Updated API linking signature to use Apis
src/wasm.rs Adjusted store creation and parallel module compilation logic
src/lib.rs Modified admin and help command handling to work with the new module/store structure
Cargo.toml Added rayon dependency for parallel processing

// Create APIs directly for the module
let apis = match Apis::new(name.clone(), db.clone()) {
Ok(apis) => apis,
Err(_) => return None,
Copy link

Copilot AI Apr 25, 2025

Choose a reason for hiding this comment

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

In the parallel module compilation block, errors from Apis::new are silently swallowed (returning None) which can make debugging difficult. Consider logging the error details before returning None.

Suggested change
Err(_) => return None,
Err(e) => {
tracing::error!("Failed to create APIs for module '{}': {}", name, e);
return None;
},

Copilot uses AI. Check for mistakes.
Comment on lines +140 to +141
if apis::Apis::link(&mut linker).is_err() {
return None;
Copy link

Copilot AI Apr 25, 2025

Choose a reason for hiding this comment

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

The linking failure is handled by immediately returning None without logging the error. It is advisable to log error information to aid in troubleshooting module linking issues.

Suggested change
if apis::Apis::link(&mut linker).is_err() {
return None;
match apis::Apis::link(&mut linker) {
Ok(_) => {}
Err(e) => {
tracing::error!("Failed to link APIs for module: {name}. Error: {e}");
return None;
}

Copilot uses AI. Check for mistakes.
@bnjbvr
Copy link
Owner Author

bnjbvr commented May 5, 2025

superseded by #81

@bnjbvr bnjbvr closed this May 5, 2025
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