Repository navigation
Conversation
Replace `.map(...).join('')` inside the React render cycle of `CodeBlock` with manual loops. This prevents allocating multiple short-lived arrays and strings on every UI frame during streaming updates.
Co-authored-by: bobdivx <6737167+bobdivx@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. |
Understood. Acknowledging that this work is a micro-optimization and that the PR is closed. I am stopping work on this task. |
💡 What: Replaced
.map(l => l.map(t => t.content).join('')).join('\n')insideCodeBlock.tsxwith a manual length-check and loop.🎯 Why: During streaming, the text updates extremely frequently causing
CodeBlockto re-render. SinceCodeBlockwasn't manually checking equivalency efficiently, it allocated strings and intermediate arrays recursively for each token line, creating O(N_lines) allocations on every single render.📊 Impact: Reduces memory allocation significantly (from O(lines) allocations per render to exactly 0 array allocations per render and a max of 1 string allocation per render).
🔬 Measurement:
pnpm run test:webwas verified to pass, which confirms the text extraction and matching logic handles tokens properly. Can also be measured via the React profiler noticing significantly less GC pauses while printing codeblocks.PR created automatically by Jules for task 16760445138835874973 started by @bobdivx