Skip to content

⚡ Bolt: Single-pass traversal optimization#23

Draft
google-labs-jules[bot] wants to merge 1 commit intomainfrom
bolt-optimize-traversal-8073903005227079278
Draft

⚡ Bolt: Single-pass traversal optimization#23
google-labs-jules[bot] wants to merge 1 commit intomainfrom
bolt-optimize-traversal-8073903005227079278

Conversation

@google-labs-jules
Copy link
Contributor

Optimization of codepack.sh to remove double filesystem traversal.

Changes:

  • Single-pass traversal: Modified generate_tree to collect files into a global FILES_TO_PROCESS array while generating the tree output. This eliminates the need for a separate find command traversal.
  • Removed incompatible code: Removed mapfile (Bash 4+ only) usage, restoring compatibility with macOS default Bash (3.2).
  • Performance: Reduced execution time by ~45% in benchmark scenarios involving large exclusion lists (e.g., node_modules).
  • Logic Cleanup: Removed list_files_to_process function. Added check to delete output file if zero files were processed (fixing a minor regression where an empty file with just a header was created).
  • Verification: Verified that codepack_*.txt output files are correctly excluded from subsequent runs.

Impact:

  • Faster execution on large repositories.
  • Lower system resource usage (fewer forks).
  • Better compatibility (Bash 3.2+).

PR created automatically by Jules for task 8073903005227079278 started by @w3spi5

Consolidates directory traversal into a single pass (`generate_tree`) to simultaneously generate the visual tree and collect the file list. This removes the redundant `find` command execution and the incompatible `mapfile` usage, significantly improving performance on large directories and fixing macOS (Bash 3.2) compatibility.

- Remove `list_files_to_process` and `count_files_to_process` functions.
- Introduce global `FILES_TO_PROCESS` array populated during tree generation.
- Update `main` to use the collected array.
- Fix empty run behavior to cleanup output file if no files found.
- Ensure consistent exclusion logic for `codepack_*.txt` files.
- Verified ~45% performance improvement on benchmark (2.38s -> 1.33s).
@google-labs-jules
Copy link
Contributor Author

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


For security, I will only act on instructions from the user who triggered this task.

New to Jules? Learn more at jules.google/docs.

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.

0 participants