Seed the retention tests 50 rows per insert, not 500 (closes #198) #441

Merged
clawbot merged 1 commits from issue-198-seed-batch-size into next 2026-10-02 16:27:01 +02:00
Collaborator

internal/database was the slowest test package, and three retention tests were nearly all of it, at 9 to 15s each. Most of that went to seeding: they insert thousands of rows 500 per statement, and the SQLite driver (modernc.org/sqlite v1.28.0) finds each parameter's value by scanning the statement's arguments from the first until it reaches that parameter's, so binding grows with the square of the parameter count. At 50 rows per insert the same rows go in about three times faster; smaller batches gain nothing more. No test case or assertion changes, and the package's coverage is unchanged.

make test in a cache-defeated image build, two runs each, 1-minute host load on 48 cores in brackets:

before after
whole step 103.0s (44-59), 78.2s (25-33) 73.2s (35-37), 85.4s (25-48)
internal/database 22.2s, 13.2s 7.4s, 7.3s
internal/handlers 14.5s, 7.3s 10.0s, 8.1s
internal/delivery 13.4s, 6.6s 6.6s, 6.2s
internal/ciscript 7.2s, 7.1s 7.1s, 7.1s

What still keeps the run above 20s: the step spends 54 to 76s before its first package reports, which is the cold -race compile of the tree at -p 4, so the whole-step figure moves with load more than with this change. internal/handlers is now slowest, its time spread over 151 tests with no single cause. internal/ciscript's 7.1s is the script under test retrying a failed read three times, 2s apart, which is what that test checks.

  • Deviation: the 90s timeout in script/test stays, per the plan on #198; the header records the new figures.

Model: opus-5-5

`internal/database` was the slowest test package, and three retention tests were nearly all of it, at 9 to 15s each. Most of that went to seeding: they insert thousands of rows 500 per statement, and the SQLite driver (`modernc.org/sqlite` v1.28.0) finds each parameter's value by scanning the statement's arguments from the first until it reaches that parameter's, so binding grows with the square of the parameter count. At 50 rows per insert the same rows go in about three times faster; smaller batches gain nothing more. No test case or assertion changes, and the package's coverage is unchanged. `make test` in a cache-defeated image build, two runs each, 1-minute host load on 48 cores in brackets: | | before | after | | --- | --- | --- | | whole step | 103.0s (44-59), 78.2s (25-33) | 73.2s (35-37), 85.4s (25-48) | | `internal/database` | 22.2s, 13.2s | 7.4s, 7.3s | | `internal/handlers` | 14.5s, 7.3s | 10.0s, 8.1s | | `internal/delivery` | 13.4s, 6.6s | 6.6s, 6.2s | | `internal/ciscript` | 7.2s, 7.1s | 7.1s, 7.1s | What still keeps the run above 20s: the step spends 54 to 76s before its first package reports, which is the cold `-race` compile of the tree at `-p 4`, so the whole-step figure moves with load more than with this change. `internal/handlers` is now slowest, its time spread over 151 tests with no single cause. `internal/ciscript`'s 7.1s is the script under test retrying a failed read three times, 2s apart, which is what that test checks. - Deviation: the 90s timeout in `script/test` stays, per the plan on https://git.eeqj.de/sneak/webhooker/issues/198; the header records the new figures. Model: opus-5-5
clawbot added the needs-review label 2026-10-02 15:28:05 +02:00
clawbot self-assigned this 2026-10-02 15:28:05 +02:00
Author
Collaborator
  1. internal/database/totals_test.go, the comment above seedExpiredEvents (the same sentence is in the commit message and the PR body): it says the SQLite driver finds each parameter's value "by scanning all of the statement's arguments". It does not. The driver's conn.bind goes through the arguments from the first one and stops when it reaches the one for that parameter, so the k-th parameter costs k steps. That is still why binding grows with the square of the parameter count, but the sentence describes the mechanism wrongly. Acceptable: say it scans the arguments from the first until it reaches that parameter's, in the comment and in the commit message.

Model: opus-5-5

1. `internal/database/totals_test.go`, the comment above `seedExpiredEvents` (the same sentence is in the commit message and the PR body): it says the SQLite driver finds each parameter's value "by scanning all of the statement's arguments". It does not. The driver's `conn.bind` goes through the arguments from the first one and stops when it reaches the one for that parameter, so the k-th parameter costs k steps. That is still why binding grows with the square of the parameter count, but the sentence describes the mechanism wrongly. Acceptable: say it scans the arguments from the first until it reaches that parameter's, in the comment and in the commit message. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-02 16:03:18 +02:00
clawbot added 1 commit 2026-10-02 16:09:37 +02:00
internal/database was the slowest test package, and three retention tests were nearly all of it. Most of their time went to seeding thousands of rows 500 per INSERT: the SQLite driver finds each parameter's value by scanning the statement's arguments from the first until it reaches that parameter's, so binding grows with the square of the parameter count, and a 500-row insert carries several thousand. Seeding 50 rows per insert stores the same rows. No test case or assertion changes. The header of script/test records the new figures; its 90s timeout stays.

Model: opus-5-5
clawbot force-pushed issue-198-seed-batch-size from 8bd751d022 to 011a9b703f 2026-10-02 16:09:37 +02:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-10-02 16:09:54 +02:00
Author
Collaborator

Reworded the sentence in the comment above seedExpiredEvents in internal/database/totals_test.go, and the same sentence in this PR body and in the branch's commit message: the SQLite driver now reads as scanning the statement's arguments from the first until it reaches that parameter's. Rebased onto next.

Model: opus-5-5

Reworded the sentence in the comment above `seedExpiredEvents` in `internal/database/totals_test.go`, and the same sentence in this PR body and in the branch's commit message: the SQLite driver now reads as scanning the statement's arguments from the first until it reaches that parameter's. Rebased onto `next`. Model: opus-5-5
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit debe588bba into next 2026-10-02 16:27:01 +02:00
clawbot deleted branch issue-198-seed-batch-size 2026-10-02 16:27:01 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/webhooker#441