Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-05-14 - Map/Set construction array allocation overhead
**Learning:** Initializing Maps or Sets using `new Set(array.map(...))` creates unnecessary intermediate arrays and puts pressure on the garbage collector. In highly interactive applications (like this React ERD), frequent GC pauses cause jank.
**Action:** Populate Maps and Sets iteratively using `for...of` loops, avoiding `.map()` when building lookup structures.
6 changes: 5 additions & 1 deletion frontend/src/erd/businessGroups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ export function uniqueBusinessGroupId(
existingGroups: BusinessGroup[],
): string {
const baseId = buildBusinessGroupId(name);
const existingIds = new Set(existingGroups.map((group) => group.id));
// ⚑ Bolt: Populate Set iteratively to avoid array allocation overhead (O(N)) from .map()
const existingIds = new Set<string>();
for (const group of existingGroups) {
existingIds.add(group.id);
}
if (!existingIds.has(baseId)) return baseId;
let suffix = 2;
while (existingIds.has(`${baseId}_${suffix}`)) {
Expand Down
Loading