⚡ perf: optimize generateFileSystemTree with concurrent execution#1
⚡ perf: optimize generateFileSystemTree with concurrent execution#1megawron wants to merge 4 commits into
generateFileSystemTree with concurrent execution#1Conversation
This replaces a sequential `for...of` loop with `Promise.all` + `.map`, allowing file I/O operations (like `fs.stat` and `fs.readFile`) to be performed concurrently for children within a directory. This fixes an N+1 query pattern and provides significant performance improvements when traversing large directories. Co-authored-by: megawron <52606827+megawron@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
…logic works
This fixes build failures in CI:
1. `build.mjs` was using `Bun.write` in a loop that hit a directory inside `lib/` (like `lib/services`), causing an `EISDIR` error. Replaced it with Node's `cp(..., { recursive: true })` which correctly copies nested directories.
2. The Wasm tagger's build script `lib/frameworks/engines/tagger-rs/build_wasm.sh` only copied the `.wasm` file to `lib/` and failed to copy the JS glue code `zerocms_tagger.js`, which was being imported in `lib/frameworks/engines/WasmEngine.js`. Updated the script to copy `zerocms_tagger.js` as well, resolving the missing import during the build.
Co-authored-by: megawron <52606827+megawron@users.noreply.github.com>
…logic works
This fixes build failures in CI:
1. `build.mjs` was using `Bun.write` in a loop that hit a directory inside `lib/` (like `lib/services`), causing an `EISDIR` error. Replaced it with Node's `cp(..., { recursive: true })` which correctly copies nested directories.
2. The Wasm tagger's build script `lib/frameworks/engines/tagger-rs/build_wasm.sh` only copied the `.wasm` file to `lib/` and failed to copy the JS glue code `zerocms_tagger.js`, which was being imported in `lib/frameworks/engines/WasmEngine.js`. Updated the script to copy `zerocms_tagger.js` as well, resolving the missing import during the build.
Co-authored-by: megawron <52606827+megawron@users.noreply.github.com>
Ensures that directories in `lib` are fully copied during build. Ensures that the JS glue script for the Wasm tagger is accurately copied into `lib`. Co-authored-by: megawron <52606827+megawron@users.noreply.github.com>
💡 What: Replaced the sequential
for...ofloop ingenerateFileSystemTreewith a concurrentPromise.allmapping.🎯 Why: The previous code awaited
fs.statandfs.readFile/ recursive calls sequentially, creating an N+1 query pattern where directory entries were processed one by one. Moving toPromise.allallows the underlying I/O operations to be dispatched concurrently, significantly speeding up file tree generation.📊 Measured Improvement: In a local benchmark traversing a dummy structure with 50 files and 5 directories (with 10 sub-files each) for 5 iterations:
PR created automatically by Jules for task 126769711835250462 started by @megawron