optimize command execution by reducing redundant clones - #1
optimize command execution by reducing redundant clones#1google-labs-jules[bot] wants to merge 1 commit into
Conversation
This commit optimizes the bootstrap build system by: 1. Changing `CommandOutput` to use `Arc<[u8]>` instead of `Vec<u8>` for captured stdout/stderr. This makes `CommandOutput` cloning O(1) and avoids redundant data copying when retrieving command results from the cache. 2. Avoiding redundant `fingerprint()` calculations in `DeferredCommand::finish_process` by passing the already existing fingerprint from the caller. These changes reduce memory allocations and data copying during the build process, especially for commands that are frequently cached or have large outputs.
|
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 `. 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. |
This PR optimizes the
src/bootstraptool by reducing unnecessary data cloning and redundant calculations.💡 What:
CommandOutputto storestdoutandstderrasOption<Arc<[u8]>>instead ofOption<Vec<u8>>.finish_processto accept a pre-calculatedCommandFingerprintinstead of recalculating it from theBootstrapCommand.🎯 Why:
CommandOutputis frequently cloned when retrieved from theCommandCacheor during step execution. WithVec<u8>, this was anArc<[u8]>, it'scommand.fingerprint()is a relatively expensive operation that clones all command arguments and environment variables. Calling it again infinish_processwas redundant since the fingerprint was already available inwait_for_output.📊 Impact:
🔬 Measurement:
python3 x.py check src/bootstrapandpython3 x.py test src/bootstrap.PR created automatically by by @lang-tempo