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 @@ -3,3 +3,6 @@
**Learning:** `Date.parse(value)` returns the timestamp primitive directly, while `new Date(value).getTime()` also constructs a `Date` object. Both use the same ECMAScript string-parsing semantics for these call sites.

**Action:** In frequently executed paths that only need a timestamp primitive, prefer `Date.parse(value)`. Treat the allocation reduction as a bounded micro-optimization unless a committed benchmark establishes a larger runtime effect.
## 2023-10-12 - [Array Iteration Optimization in Session Export]
**Learning:** Chained `.map(...).filter(...)` operations on large arrays allocate an intermediate array which creates GC overhead. This is problematic on hot paths like dashboard data endpoints.
**Action:** Replace `.map().filter()` chains with a single `.reduce()` pass for array aggregations to minimize allocations and GC pause times.
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,11 @@ export async function GET(
include: sessionInclude,
})
const byId = new Map(rows.map((s) => [s.id, s]))
csvSessions = ids
.map((id) => byId.get(id))
.filter((s): s is SessionWithInclude => !!s)
csvSessions = ids.reduce((acc, id) => {
const s = byId.get(id)
if (s) acc.push(s)
return acc
}, [] as SessionWithInclude[])
}
} else {
csvSessions = await db.claudeSession.findMany({
Expand Down Expand Up @@ -245,9 +247,11 @@ export async function GET(
include: sessionInclude,
})
const byId = new Map(rows.map((s) => [s.id, s]))
sessions = ids
.map((id) => byId.get(id))
.filter((s): s is SessionWithInclude => !!s)
sessions = ids.reduce((acc, id) => {
const s = byId.get(id)
if (s) acc.push(s)
return acc
}, [] as SessionWithInclude[])
}
} else {
const [rows, countResult] = await Promise.all([
Expand Down
Loading