Repository navigation
Commit aad035b
fix(api): load sheets sequentially at boot to avoid OOM spike
A cold boot OOM'd (FATAL: Reached heap limit) building in-memory state from the
full `published` import. Per-phase heap instrumentation in the live pod traced
it to `loadInMemoryState` reading all eleven sheets via Promise.all: every
sheet's transient read/decompress/parse buffers peaked simultaneously, blowing
past a 1.5 GB heap — even though the retained state is only ~0.5 GB.
Read the sheets sequentially instead. Same records, same order, same retained
footprint; the peak is bounded to the single largest sheet. Boot is not
latency-sensitive, so the serialization costs nothing in practice. Verified:
the live pod boots to /api/health/ready in ~0.48 GB on the standard node size.
Tracked against #132 (heap footprint).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent ef79e0c commit aad035b
1 file changed
Lines changed: 20 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
54 | 47 | | |
55 | 48 | | |
56 | 49 | | |
| |||
0 commit comments