Write batches through one connection with a 1 GiB cache, in key order (closes #96)
check / check (push) Canceled after 0s

Every write now uses one connection taken from the pool when the
database opens, under the database lock. Its 1 GiB page cache keeps
the pages the route writes touch from one batch to the next. A reading
connection's cache is emptied whenever another connection has written,
so the 9 reading connections drop to 16 MiB each. The soft and hard
heap limits rise to 1.5 and 2 GiB, above the caches; README "Memory"
adds up the new budget. Vacuum, Analyze and Checkpoint check their
context after the lock, which the kept connection does not. Batch
writes sort their rows by peer, then prefix. The benchmark also times
the largest prefix handler batch, 250,000 updates.

Model: opus-5-5
This commit is contained in:
2026-10-19 12:53:52 +00:00
parent 1f612642e3
commit 4c2882c19c
4 changed files with 296 additions and 72 deletions
+2 -2
View File
@@ -18,12 +18,12 @@ func logSlowQuery(logger *logger.Logger, query string, start time.Time) {
}
}
// exec wraps Exec with slow query logging
// exec runs a statement on the writing connection, with slow query logging
func (d *Database) exec(query string, args ...any) error {
start := time.Now()
defer logSlowQuery(d.logger, query, start)
_, err := d.db.ExecContext(context.Background(), query, args...)
_, err := d.writer.ExecContext(context.Background(), query, args...)
return err
}