perf(database-watt): cut an upload from 12 messages to 6 #3
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 444 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.365
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #3"
general
weight: 0.35
ShogunPanda
An upload cost the storage worker 12 messages to the Database application: one for the bucket read, two for the permission probe before the S3 upload (the probe, then ROLLBACK), and nine for the write (the lock, the bucket and object reads, SAVEPOINT, the caller's probe, ROLLBACK TO and RELEASE SAVEPOINT, the INSERT, COMMIT). It now costs 6, for the same 19 statements in the same order:
testPermissiontakes asingleStatementoption, and connections that can do it providerollbackStatementExecutor(); the batch request gainsrollback. If the callback runs a second statement after all, the probe runs again as a regular transaction.database.lockedBatchmessage) or with COMMIT (database.commitTransactiontakesstatements). ROLLBACK drops them; an error one raises is reported by the query it travelled with. Adatabase.cancelstops a locked batch the way it stops a locked query.- On Database Watt this means the "Failed to rollback savepoint" and "Failed to restore parent transaction scope" warnings no longer fire: such a failure fails the next statement instead, which aborts the transaction rather than carrying on under the wrong scope. A 25P02 from SAVEPOINT is mapped by that statement's error handling.
- If a request carrying deferred statements is cancelled in flight, whether they ran is unknown, so the transaction can then only be rolled back.
Database.lockObjectForWrite). A lock timeout is still reported as LockTimeout and a missing bucket as NoSuchBucket.- On Database Watt the upload's
WaitObjectLock,FindBucketByIdandFindObjectquery timings become oneLockObjectForWrite, so dashboards or alerts keyed on those names will see uploads drop out of them.The direct pg path keeps running these steps one by one.
| Part of an upload | Messages before | Messages after |
|---|---:|---:|
| Bucket read | 1 | 1 |
| Permission probe | 2 | 1 |
| Write: BEGIN, scope, lock, bucket and object reads | 3 | 1 |
| Write: SAVEPOINT and the caller's probe | 2 | 1 |
| Write: ROLLBACK TO, RELEASE SAVEPOINT and the INSERT | 3 | 1 |
| Write: COMMIT | 1 | 1 |
| Total | 12 | 6 |
The integration tests check the probe's and the write's counts against the Database application's own message stats. Inside the Database application, the same upload takes 9 round trips to Postgres instead of 15.
Measured in Docker on one machine, with 4 storage workers, the Database application and pipelining on. The load was 1 KB upserts as service_role, this branch against 05aae5a6, medians of six rounds in alternating order:
| | Before | After |
|---|---:|---:|
| Database thread CPU per upload, 200 uploads/s | 1,592 µs | 1,222 µs |
| Database thread CPU per upload, saturated | 1,146 µs | 964 µs |
| Postgres CPU per upload, 200 uploads/s | 2,316 µs | 2,094 µs |
| Median upload latency, 200 uploads/s | 19.7 ms | 17.8 ms |
The Database thread's figures were lower in every round, and Postgres CPU in five rounds of six. Halving the messages takes about a fifth off the Database thread's cost of an upload; the rest goes on the 19 statements themselves, which this does not change. Saturated throughput moved with the machine's load, and each build had the faster run in three rounds of six, so it is not quoted.