Finding — Asymptotic space complexity: O(E), unbounded
Subsystem: Persist — FileStore (src/persist.ts:22–37), MemoryStore (src/persist.ts:96–103), Manager (src/manager.ts:72,99)
Input variable
E = total enqueue+dequeue operations over process lifetime
Current complexity
- Space: O(E), unbounded — never compacted during operation
Cause
Every enqueue() and dequeue() unconditionally calls this.store.saveEvent(...) (src/manager.ts:72,99), regardless of whether persistence is enabled.
- FileStore:
saveEvent appends to persist.dat without compaction. The file grows with every operation until the process restarts. Only save() at shutdown or load() at startup compact it.
- MemoryStore (persistence disabled, i.e.
--persist flag absent): saveEvent pushes to an in-memory events[] array that is never read and never cleared — a pure memory leak with no benefit.
main.ts:15–17 selects MemoryStore when persistEnabled is false; manager.ts:72,99 calls saveEvent unconditionally; neither MemoryStore.events nor persist.dat is compacted during operation.
Remediation direction
- For MemoryStore with persistence disabled: make
saveEvent a no-op.
- For FileStore: periodic snapshot compaction (clear + rewrite current state) or write-ahead log with checkpoints.
Confidence
High — source analysis. No long-running runtime measurement; impact scales with uptime and traffic volume.
Finding — Asymptotic space complexity: O(E), unbounded
Subsystem: Persist — FileStore (
src/persist.ts:22–37), MemoryStore (src/persist.ts:96–103), Manager (src/manager.ts:72,99)Input variable
E= total enqueue+dequeue operations over process lifetimeCurrent complexity
Cause
Every
enqueue()anddequeue()unconditionally callsthis.store.saveEvent(...)(src/manager.ts:72,99), regardless of whether persistence is enabled.saveEventappends topersist.datwithout compaction. The file grows with every operation until the process restarts. Onlysave()at shutdown orload()at startup compact it.--persistflag absent):saveEventpushes to an in-memoryevents[]array that is never read and never cleared — a pure memory leak with no benefit.main.ts:15–17selects MemoryStore whenpersistEnabledis false;manager.ts:72,99calls saveEvent unconditionally; neitherMemoryStore.eventsnorpersist.datis compacted during operation.Remediation direction
saveEventa no-op.Confidence
High — source analysis. No long-running runtime measurement; impact scales with uptime and traffic volume.