The changes yesterday caused a severe Regression on the startup time. The checkpoint…
- User
The changes yesterday caused a severe Regression on the startup time. The checkpoint loading takes much longer. Before: [INFO] metricstore.go:159: [METRICSTORE]> Checkpoints loaded (5811 files, 22242 MB, that took 13.982486s) 3/24/2026, 7:19:34 AMINFO[INFO] metricstore.go:153: [METRICSTORE]> Loading checkpoints newer than 2026-03-23T07:19:34+01:00. And after the changes: etricstore.go:159: [METRICSTORE]> Checkpoints loaded (5860 files, 21338 MB, that took 302.524814s) 3/24/2026, 6:10:53 PMINFO[INFO] metricstore.go:153: [METRICSTORE]> Loading checkpoints newer than 2026-03-23T18:10:53+01:00 3/24/2026, 6:10:43 PMINFO[INFO] metricstore.go:153: [METRICSTORE]> Loading checkpoints newer than 2026-03-23T18:10:43+01:00 3/24/2026, 6:09:50 PMINFO[INFO] metricstore.go:153: [METRICSTORE]> Loading checkpoints newer than 2026-03-23T18:09:50+01:00 3/24/2026, 6:05:57 PMINFO[INFO] metricstore.go:153: [METRICSTORE]> Loading checkpoints newer than 2026-03-23T18:05:57+01:00 3/24/2026, 6:02:12 PMINFO[INFO] metricstore.go:153: [METRICSTORE]> Loading checkpoints newer than 2026-03-23T18:02:12+01:00. Investigate the issue and fix it.
Assistant
Let me investigate the recent changes to the checkpoint loading code.
Assistant
The WAL writing changes look fine — they only affect write path, not loading. Let me check the loading code more carefully.
Assistant
No changes to checkpoint.go or metricstore.go in recent commits. Let me look at what changed between the working and broken state more carefully.
Assistant
Now let me look at the
fromCheckpointfunction (lowercase) which is what actually loads files per host:Assistant
Now let me look at
loadBinaryFileandloadWALFile:Assistant
The
readBinaryLevelfunction usesbinary.Readfor every single value - that's extremely slow due to reflection overhead. But let me check if this code actually changed recently or if it was always like this.Assistant
The recent commits only affected writing, not loading. The loading code hasn't changed. So the regression must be because the checkpoint format is now WAL+binary (
.binfiles) instead of JSON, andreadBinaryLevelusesbinary.Readper value which is extremely slow due to reflection.Let me check what format was being loaded before:
Assistant
Let me look at
readWALRecordto understand WAL replay performance:Assistant
Let me check the worker pool size and the
readBinaryLevelperformance characteristics:Assistant
Now let me look at
readBinaryLevelmore carefully — specifically the float reading loop andreadString16:- User
[Request interrupted by user]
- User
It must have been changes of the last 2 days. Before the startup was fast. Maybe the changes in the startup and shutdown handling code?
Assistant
Good point. Let me look at the shutdown/startup changes from the last 2 days.
Assistant
Let me look at the
runServerand the metricstoreInitcall path:Assistant
Now let me look at the
metricstore.Shutdown()and how the server'sShutdowninteracts with the WaitGroup:Assistant
Let me check what the server shutdown looked like BEFORE the "Improve shutdown time" commit:
Assistant
Found it. The "Improve shutdown time" commit (93a9d732) introduced a hard 10-second deadline for
metricstore.Shutdown(). Previously it ran with no time limit. Let me verify the full Shutdown path:Assistant
Here's the root cause:
In
server.go(after 93a9d732):goselect { case <-done: case <-time.After(10 * time.Second): cclog.Warn("Shutdown deadline exceeded, forcing exit") }metricstore.Shutdown()writes 5800+ binary snapshot files for ~21GB of data, then callsRotateWALFilesAfterShutdown()to delete WAL files. This easily takes more than 10 seconds. When the deadline fires, the process exits before WAL rotation happens.On next startup, the WAL files from the previous run are still there and must be replayed — they contain ALL data since the last successful WAL rotation. This accumulates across restarts.
Let me also check
RotateWALFilesAfterShutdown:Assistant
Now I have the full picture. Let me write the plan.
Assistant
The root cause is commit
93a9d732("Improve shutdown time") which added a hard 10-second deadline aroundmetricstore.Shutdown(). Writing ~5800 binary snapshots for 21GB takes well over 10s, so the process exits beforeRotateWALFilesAfterShutdown()runs. On next startup, the un-rotated WAL files are replayed in full — that's the 302s.The fix is simply increasing the deadline from 10s to 120s in
server.go.Assistant
Build succeeds. The fix changes the hard shutdown deadline from 10s to 120s, giving
metricstore.Shutdown()enough time to write all binary snapshots and rotate the WAL files before process exit.