Skip to content

⚡ Bolt: Optimize DocxXMLEditor ID generation#8

Open
timteh wants to merge 1 commit intomainfrom
bolt-docx-optimization-2205038832139254445
Open

⚡ Bolt: Optimize DocxXMLEditor ID generation#8
timteh wants to merge 1 commit intomainfrom
bolt-docx-optimization-2205038832139254445

Conversation

@timteh
Copy link
Copy Markdown
Owner

@timteh timteh commented Feb 2, 2026

⚡ Bolt: Optimize DocxXMLEditor ID generation

💡 What

Modified skills/docx/scripts/document.py to cache the next available tracked change ID in DocxXMLEditor.

🎯 Why

The previous implementation scanned the entire DOM (using getElementsByTagName) every time a new tracked change (insertion or deletion) was added to find the maximum existing ID. This caused performance to degrade linearly with document size and the number of insertions ($O(N \cdot M)$).

📊 Impact

  • 20x Speedup for batch insertions in large documents.
  • Reduced time for 50 insertions in a 20k paragraph document from 4.06s to 0.20s.

🔬 Measurement

Created a reproduction script repro_perf.py that generates a large XML document and inserts tracked changes.

  • Baseline: 4.06s
  • Optimized: 0.20s

PR created automatically by Jules for task 2205038832139254445 started by @timteh

Optimized `DocxXMLEditor._get_next_change_id` to cache the next available change ID instead of scanning the full DOM every time.

- Reduces complexity from O(N*M) to O(M+N) for N insertions in a document of size M.
- Measured 20x speedup (4.06s -> 0.20s) for inserting 50 tracked changes in a 20k paragraph document.
- Ensures ID uniqueness while avoiding redundant traversals.

Co-authored-by: timteh <211128536+timteh@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown

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

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