perf: optimize worktree lookup by combining awk processes#2
Conversation
|
👋 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. |
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>
2ca2fe7 to
312ffec
Compare
💡 What:
The optimization merges the worktree filtering logic directly into the
list_worktreesfunction'sawkscript. It adds an optionaltargetargument tolist_worktreeswhich, when provided, makesawkprint only the matching worktree's path and exit early.🎯 Why:
Previously,
goto_worktreeandremove_worktreewere callinglist_worktreesand then piping its output into anotherawkprocess. This involved redundant process creation and full stream processing even after a match was found.📊 Measured Improvement:
Measured using 100 iterations of
goto_worktreeon a repository with 20 worktrees:PR created automatically by Jules for task 740662979427547415 started by @RodrigoEspinosa