Finding — Asymptotic time complexity: O(E)
Subsystem: Persist (src/persist.ts:50–86)
Input variable
E = events in persist.dat
Current complexity
- Time: O(E)
- Space: O(E) — with 3× peak memory:
content.split("\n") creates O(E) strings, .filter(...) creates another O(E) array, .map(...) creates a third O(E) array of parsed objects (lines 73–75)
Cause
loadState() reads the entire file into memory via a chunked read loop, decodes it, then chains content.split("\n").filter(...).map(...) — creating three intermediate arrays before returning the result.
Evidence
| Events |
Time (median) |
| 1,000 |
0.31 ms |
| 10,000 |
2.68 ms |
| 20,000 |
5.51 ms |
Linear. Not a bottleneck by itself, but it is the linear component that combines with the quadratic replay in load(). The 3× temporary array allocation is a space concern for large files.
Runtime: Deno 2.7.6, V8 14.6.202.9-rusty, darwin (Apple Silicon)
Remediation direction
Stream-parse line-by-line (O(1) peak memory per line, no intermediate arrays).
Confidence
High — source analysis + benchmark.
Finding — Asymptotic time complexity: O(E)
Subsystem: Persist (
src/persist.ts:50–86)Input variable
E= events in persist.datCurrent complexity
content.split("\n")creates O(E) strings,.filter(...)creates another O(E) array,.map(...)creates a third O(E) array of parsed objects (lines 73–75)Cause
loadState()reads the entire file into memory via a chunked read loop, decodes it, then chainscontent.split("\n").filter(...).map(...)— creating three intermediate arrays before returning the result.Evidence
Linear. Not a bottleneck by itself, but it is the linear component that combines with the quadratic replay in
load(). The 3× temporary array allocation is a space concern for large files.Runtime: Deno 2.7.6, V8 14.6.202.9-rusty, darwin (Apple Silicon)
Remediation direction
Stream-parse line-by-line (O(1) peak memory per line, no intermediate arrays).
Confidence
High — source analysis + benchmark.