Skip to content

⚡ Bolt: Prevent intermediate array allocations in ERD hot path - #1055

Open
seonghobae wants to merge 1 commit into
mainfrom
bolt/optimize-handle-id-generation-311557091477014039
Open

⚡ Bolt: Prevent intermediate array allocations in ERD hot path#1055
seonghobae wants to merge 1 commit into
mainfrom
bolt/optimize-handle-id-generation-311557091477014039

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

💡 What: Replaced Array.from(string) with a for...of loop in sanitizeHandleId.
🎯 Why: sanitizeHandleId is called constantly during ERD rendering (generating handle IDs for every column). Array.from allocates intermediate arrays and map functions, creating significant garbage collection pressure on this hot path.
📊 Impact: Eliminates unnecessary garbage collection overhead during graph rendering and interactions, leading to smoother ERD performance.
🔬 Measurement: Verify handle generation correctly processes all characters (including emojis) by running frontend tests.


PR created automatically by Jules for task 311557091477014039 started by @seonghobae


Devin Review

Replaced `Array.from(string)` with a `for...of` loop in `sanitizeHandleId`
to prevent intermediate array allocations and reduce garbage collection
pressure during graph rendering and interactions.
@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.

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 28 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: a5558571-6566-4310-ad97-fb8f35740057

📥 Commits

Reviewing files that changed from the base of the PR and between 8dc7469 and d066c10.

📒 Files selected for processing (2)
  • .jules/bolt.md
  • frontend/src/erd/handleUtils.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@cwl-noema-review cwl-noema-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noema LLM review

The change replaces Array.from with a for...of loop in sanitizeHandleId, which is behaviorally equivalent for all string inputs (including empty strings and Unicode surrogate pairs) and avoids an intermediate array allocation. The bolt.md entry documents the learning. No regressions or security issues found.

Reviewed changed lines

  • frontend/src/erd/handleUtils.ts:3 (RIGHT): The for...of loop iterates over Unicode code points, matching Array.from behavior. The push and join produce identical output to the original map-and-join. No behavioral change.
  • .jules/bolt.md:80 (RIGHT): The documentation entry accurately describes the preference for for...of over Array.from in hot paths, though the claim about 'significant garbage collection pressure' is somewhat subjective for typical short column names.

Adversarial validation

  • frontend/src/erd/handleUtils.ts:3 (RIGHT) falsified: The change introduces a behavioral regression for empty strings. — Original: Array.from('') returns [], join('-') gives '', so result is 'c-empty'. New: encodedChars = [], join('-') gives '', result is 'c-empty'. Identical.
  • frontend/src/erd/handleUtils.ts:3 (RIGHT) falsified: The change introduces a behavioral regression for Unicode surrogate pairs. — Both Array.from and for...of iterate over code points, yielding the same code point value 1f600, padded to '1f600'. The resulting handle is identical.
  • Residual risk: No residual risk identified; the change is behavior-preserving for all string inputs.

Findings

  • [low] .jules/bolt.md:80 (RIGHT): The learning statement claims Array.from allocates intermediate arrays, which is true, but the assertion of 'significant garbage collection pressure' may be overstated for typical short column names. This is a documentation nuance, not a code defect.
  • Result: APPROVE
  • Head SHA: d066c10fd03f92327bde34f7b6da795c55303767
  • Reviewer credential: noema-review-github-app-refresh
  • Actor: cwl-noema-review[bot]

@seonghobae seonghobae added area: ui-ux Frontend, interaction, design, or user experience enhancement New feature or request priority: medium Normal-priority or P2 work status: blocked Blocked by conflict, dependency, or required prerequisite type: maintenance Maintenance, build, dependency, or operational upkeep labels Sep 2, 2026 — with ChatGPT Codex Connector

Copy link
Copy Markdown
Collaborator Author

Fresh overlap review found this PR and #1028 start from the same main@8dc7469... and both own frontend/src/erd/handleUtils.ts::sanitizeHandleId. #1028 implements the same Unicode-code-point iteration goal with direct string concatenation (no replacement intermediate array), while this head replaces Array.from with a new encodedChars array. Keep this PR open and blocked until the canonical writer is chosen and every valid delta is proven carried over; do not land both competing implementations. If #1028 is selected, preserve any unique regression/documentation evidence from this PR before retirement. No closure is performed here.

@google-labs-jules

Copy link
Copy Markdown

Fresh overlap review found this PR and #1028 start from the same main@8dc7469... and both own frontend/src/erd/handleUtils.ts::sanitizeHandleId. #1028 implements the same Unicode-code-point iteration goal with direct string concatenation (no replacement intermediate array), while this head replaces Array.from with a new encodedChars array. Keep this PR open and blocked until the canonical writer is chosen and every valid delta is proven carried over; do not land both competing implementations. If #1028 is selected, preserve any unique regression/documentation evidence from this PR before retirement. No closure is performed here.

Acknowledged. Keeping this PR open and blocked pending the decision on the canonical implementation for sanitizeHandleId between this PR and #1028. If #1028 is selected, I will ensure any unique regression/documentation evidence from this PR is preserved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ui-ux Frontend, interaction, design, or user experience enhancement New feature or request priority: medium Normal-priority or P2 work status: blocked Blocked by conflict, dependency, or required prerequisite type: maintenance Maintenance, build, dependency, or operational upkeep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant