Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Copy a prepared instance per test, and act on a push or a finish at once

484548cd70c4ac42e4210132bcadaf8b1a8af3bc · Keenan Nemetz · 9d ago · parent 4489805d

Copy a prepared instance per test, and act on a push or a finish at once

Every test in the server package built an instance from empty files, and
creating those schemas costs about 400 ms: index.Open on a new file is 226 ms
and runs.Open 152 ms, nearly all of it DDL through the pure-Go SQLite driver,
while opening the same files again is 3 ms and 17 ms. With 253 fixtures that
was most of the package's runtime. TestMain now builds one data directory with
every schema and no rows, and a fixture copies it — a handful of small files —
so the per-test cost is the copy, not the schema.

The queue also waited on timers rather than on events, which is latency a
person feels, not just tests:

  - the push spool was read once a second, so a push's first job appeared up
    to a second later. It is read every quarter second now, and once at
    startup, so a restart also picks up what landed while the instance was
    down.
  - the lease janitor swept every five seconds whatever the lease was, so a
    two-second lease still looked dead for five. The sweep is a quarter of the
    lease, capped at five seconds, which leaves a default minute-long lease
    exactly as it was.
  - a merge-when-ready request waited for the landing sweep after its combined
    result turned green, and for the same sweep after being armed. Arming now
    notifies the landing worker through the run store, and a stored result
    notifies it from the SSH session that reports it; both still run the full
    gate, and the sweep remains the safety net.

The waits that only tests can shorten are shorter too: three spool ticks
instead of one long sleep where a test proves nothing was queued, 25 ms polls
instead of 100 ms for state the server has already changed, and the two
workflow steps that sleep only to stay running are half as long.

Measured over `go test -json`, summing per-test elapsed so parallelism cannot
hide it: the server package goes from 650 s of accumulated test time to about
275 s across the same 332 tests. In the verify container the server package's
-race run goes from 47.7 s to about 35 s, and the whole job is roughly 75 s with
the image cached.

The spool contract is unchanged: one file per ref update, consumed idempotently,
cleared when queued. leaseSweep and the run store's arming notification have
unit tests; the rest is covered by the integration tests that depended on those
timers.

Verified with `go test ./... -count=1`, `go test ./server -shuffle=on`, and
`vole workflow run verify` (which includes the race suite).

Closes: 01M87KDS5D5GCB5XGG4MW1NDQC

server/auth_test.go +4−3

@@ -637,9 +637,10 @@ jobs:
637 637 t.Fatalf("contributor push: %v\n%s", err, errs)
638 638 }
639 639
640 // The spool ticker is one second; two seconds is enough to see that ingestion
641 // deliberately skipped the tip rather than merely not having reached it.
642 deadline := time.Now().Add(2 * time.Second)
640 // The spool ticker is a quarter second; three ticks are enough to see that
641 // ingestion deliberately skipped the tip rather than merely not having
642 // reached it.
643 deadline := time.Now().Add(750 * time.Millisecond)
643 644 for time.Now().Before(deadline) {
644 645 if list, err := f.srv.Runs.Recent(f.repo, 20); err == nil {
645 646 for _, r := range list {