← Back to list
01Issue
BugShippedSwamp CLIPublic
Assigneesstack72
Relationships
#2026 writeCatalogExport takes 55-150s per workflow step — serializes entire catalog as pretty-printed JSON
Opened by magistr · 9/4/2026· Shipped 9/7/2026
Summary
writeCatalogExport in repo_context.ts runs in the per-step flush
(via stepLockHook → acquireModelLocks → flush). It iterates every
row in the SQLite catalog, serializes each with JSON.stringify(row, null, 2)
(pretty-printed), and writes them one-by-one to .catalog-export.json.
At 102k rows (post-GC; was 255k before swamp run gc), this takes 55s.
It runs after EVERY workflow step, making a 0.5s method take 55s+ wall clock.
Measured breakdown (fleet-health, single-step workflow)
| Phase | Duration |
|---|---|
| pullChanged (with per-prefix watermark fix) | 0.5s |
| Method execution | <1s |
| writeCatalogExport (102k rows) | 55s |
| pushChanged to MongoDB | 5-10s |
Root cause
- Full snapshot every step — the export writes ALL catalog rows, not just the ones that changed. For a step that writes 3 data artifacts, 102k unchanged rows are re-serialized.
- Pretty-printed JSON —
JSON.stringify(row, null, 2)produces ~3x more bytes than compact JSON. The file is consumed byswamp datastore catalog pull, which doesn't need indentation. - Per-row file.write — each row is a separate
Deno.writeFilecall instead of buffered/batched writes.
Suggested fixes (any one would help, all three together would bring it to <1s)
- Incremental export — only re-export rows that changed since the last export (track a catalog version/sequence number)
- Compact JSON —
JSON.stringify(row)instead ofJSON.stringify(row, null, 2) - Buffer writes — accumulate rows in memory and write once, or use a streaming JSON writer with a write buffer
Context
- Serve: v20260904.044433.0
- Catalog: 102k rows (after
swamp run gc --older-than 3d; was 255k before) - The pull-side bottleneck (per-prefix watermarks) was fixed in keeb/swamp-mongodb-datastore@9fde8a9 — this is the remaining overhead
02Bog Flow
Shipped
Click a lifecycle step above to view its details.
03Sludge Pulse