Skip to content

perf: reuse probe connections, WAL journaling, vendor chunk split - #5

Merged
DarknessKiller merged 3 commits into
mainfrom
perf/connection-and-vendor-chunk
Oct 17, 2026
Merged

DarknessKiller merged 3 commits into
mainfrom
perf/connection-and-vendor-chunk

Conversation

@DarknessKiller

@DarknessKiller DarknessKiller commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

Three targeted performance/stability changes, each in its own commit, all verified by build/vet/test plus local A/B evidence.

Changes

1. HTTP connection reuse across probes (internal/service/uptime)

  • Before: every HTTP probe built a fresh resty client - new connection pool, full TCP(+TLS) handshake, tore down after each request.
  • After: one long-lived client per (resolver, TLS-verify-mode) on the Service; probes dial over pooled, keep-alive connections; per-host TLS NoVerify and per-DNS dialer behavior unchanged.

2. SQLite WAL journaling (bootstrap)

  • Appends journal_mode(WAL) + synchronous(NORMAL) to the DSN; the libtnb driver already defaults busy_timeout(5000).
  • Readers no longer block during probe writes; cheaper fsync per probe.
  • Note: keep the SQLite file on local or networked-local persistent storage - WAL breaks on network filesystems.

3. Vendor chunk split (frontend)

  • react/react-dom/scheduler/axios build into a stable vendor-<hash>.js chunk.
  • On app deploys, browsers reuse the cached vendor chunk (26 kB index + 237 kB vendor vs one 288 kB blob).
  • HostDetail/NotificationManager were already lazy imports; g2plot stays out of the initial payload.

Local A/B evidence (same load shape, single variable = shared pool)

Side Probes TCP connections at target conn/probe
before 110 205 ~1.86
after 100 5 ~0.05

Verification

  • go test ./... incl. new TestService_HTTPClientReuse and TestSQLiteDSNPragmas
  • go vet ./... clean, go build ./... clean
  • vite build artifact sizes recorded above

Each HTTP probe built a fresh resty client, paying a full TCP+TLS
handshake per check and leaving no pooled connection behind. Keep one
long-lived client per (resolver, TLS verify mode) on the service; probes
now dial over reused connections. Keying keeps per-host TLS NoVerify
behavior intact, and the per-DNS dialer still bypasses per-check
re-resolution.
Concurrent probe writes and API reads contended on the default rollback
journal. Appending journal_mode(WAL) and synchronous(NORMAL) to the DSN
lets history reads proceed during writes and cuts fsync cost per probe;
the driver already supplies busy_timeout(5000).
react/react-dom/scheduler/axios now build into a vendor chunk cached
across app deploys, so repeat page loads refetch only changed app code
(26 kB index + 237 kB vendor vs one 288 kB blob). HostDetail and
NotificationManager were already lazily imported, keeping g2plot out of
the initial payload.
@DarknessKiller
DarknessKiller merged commit 1e74dcc into main Oct 17, 2026
1 check passed
@DarknessKiller
DarknessKiller deleted the perf/connection-and-vendor-chunk branch October 17, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant