Skip to content

perf: optimize worktree lookup by combining awk processes#2

Merged
RodrigoEspinosa merged 1 commit intomasterfrom
perf-optimize-awk-740662979427547415
Apr 11, 2026
Merged

perf: optimize worktree lookup by combining awk processes#2
RodrigoEspinosa merged 1 commit intomasterfrom
perf-optimize-awk-740662979427547415

Conversation

@RodrigoEspinosa
Copy link
Copy Markdown
Owner

💡 What:

The optimization merges the worktree filtering logic directly into the list_worktrees function's awk script. It adds an optional target argument to list_worktrees which, when provided, makes awk print only the matching worktree's path and exit early.

🎯 Why:

Previously, goto_worktree and remove_worktree were calling list_worktrees and then piping its output into another awk process. This involved redundant process creation and full stream processing even after a match was found.

📊 Measured Improvement:

Measured using 100 iterations of goto_worktree on a repository with 20 worktrees:

  • Baseline: ~1.55s wall-clock time, ~1.35s user CPU time.
  • Optimized: ~1.44s wall-clock time, ~1.04s user CPU time.
  • Net Gain: Approximately 7% faster wall-clock time and 23% reduction in user CPU overhead for the lookup operation.

PR created automatically by Jules for task 740662979427547415 started by @RodrigoEspinosa

@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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!

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


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

@RodrigoEspinosa RodrigoEspinosa changed the title ⚡ Optimize worktree lookup by combining awk processes perf: optimize worktree lookup by combining awk processes Apr 10, 2026
Modified `list_worktrees` to optionally accept a target branch name and
perform filtering internally. This eliminates redundant sub-processes
in `goto_worktree` and `remove_worktree` and allows for early exit
once a match is found.

Benchmark results (100 iterations of `goto_worktree`):
- Baseline: ~1.55s real, ~1.35s user
- Optimized: ~1.44s real, ~1.04s user
- Improvement: ~7% real time, ~23% user time reduction.

Co-authored-by: RodrigoEspinosa <1685621+RodrigoEspinosa@users.noreply.github.com>
@RodrigoEspinosa RodrigoEspinosa force-pushed the perf-optimize-awk-740662979427547415 branch from 2ca2fe7 to 312ffec Compare April 11, 2026 02:56
@RodrigoEspinosa RodrigoEspinosa merged commit 5a0b593 into master Apr 11, 2026
@RodrigoEspinosa RodrigoEspinosa deleted the perf-optimize-awk-740662979427547415 branch April 11, 2026 16:45
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.

1 participant