From 5ac10155eb62eb79db5f26a36d229f8af6f27bcc Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sat, 1 Aug 2026 02:01:56 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Optimize=20handle=20ID?= =?UTF-8?q?=20generation=20to=20reduce=20GC=20overhead?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .jules/bolt.md | 3 +++ frontend/src/erd/handleUtils.ts | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.jules/bolt.md b/.jules/bolt.md index f1a8c146..c8249f3e 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -77,3 +77,6 @@ Optimized metric route processing to O(N) by creating a mapping of routes direct ## 2024-07-13 - [Optimize Export Dictionary FK lookups] **Learning:** Found O(N * C * E) performance bottleneck in ERD export dictionaries due to repeated array searching with `edges.some()` inside a nested loop over nodes and columns. **Action:** Replace repeated linear array scans for edges by precomputing O(1) Set lookups of foreign key column handles per node before looping. +## 2024-07-28 - Avoid Array.from for String Iteration in High-Frequency Paths +**Learning:** Using `Array.from(string, callback).join("-")` for string processing creates unnecessary intermediate array allocations, adding garbage collection (GC) pressure, especially when executed in high-frequency paths like generating handle IDs for nodes and edges in large graphs. +**Action:** Replace `Array.from(string)` processing with a standard `for...of` loop (which natively supports Unicode code point iteration) and direct string concatenation to eliminate array allocations and improve execution speed. diff --git a/frontend/src/erd/handleUtils.ts b/frontend/src/erd/handleUtils.ts index 054d5ab2..4c1e75d4 100644 --- a/frontend/src/erd/handleUtils.ts +++ b/frontend/src/erd/handleUtils.ts @@ -1,10 +1,18 @@ export function sanitizeHandleId(columnName: string): string { - const encoded = Array.from(columnName, (char) => { - // Array.from only yields non-empty Unicode scalars, so codePointAt(0) is defined. - return char.codePointAt(0)!.toString(16).padStart(4, '0') - }).join('-') + if (!columnName) return 'c-empty'; - return `c-${encoded || 'empty'}` + let encoded = ''; + let isFirst = true; + for (const char of columnName) { + if (!isFirst) { + encoded += '-'; + } + // for...of correctly iterates over Unicode code points in JavaScript strings + encoded += char.codePointAt(0)!.toString(16).padStart(4, '0'); + isFirst = false; + } + + return `c-${encoded}`; } export function sourceColumnHandleId(columnName: string): string { From 30d5ad73c672b3ab8bed504b5453cfa80283bb84 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Mon, 3 Aug 2026 00:49:01 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Optimize=20handle=20ID?= =?UTF-8?q?=20generation=20to=20reduce=20GC=20overhead?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit