perf(daemon): rig ps resolves each seat's address once, and the lookup costs a third #4150
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.55) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.55 · 576 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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.380
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #4150"
general
weight: 0.35
mvschwarz
What a user gets
rig psanswers faster on a busy daemon, most of all when the daemon's CPU is limited. Its projection now does about a third of the work it did.What changed
getEntriesnow runs insidewithEachAddressResolvedOnce. Each address resolves once in that synchronous pass. Nothing it learned outlives the pass, so the next read still sees a rebind.resolveCurrentSessionAddressuses one reused statement: main'sWITH exact … UNION ALL alias … NOT EXISTSlookup, withexactmarkedNOT MATERIALIZED. It reads the exact row first, and the alias rows only when there's none, in one snapshot without opening a transaction. So it also works inside an open cursor and on read models that offer onlyprepare. It returns the same rows as main's statement.reusedStatement(from #3214) moves todb/reused-statement.ts, so the lookup can use it.queue-waiting.tsre-exports it.rig psreports is unchanged. There's no new refusal or error code, and no cache that outlives a read.Cost
queue-waiting.ts.Measured
The setup:
cpu.max 28000 100000, read back before and after each leg);b85c95aa), this branch, this branch, main, 0.7.25;/api/pssent 150 ms into a health read and into an attention read (10 times each), then 30 sequential/api/psreads.| Build |
psbehind a slow read (40 reads): median / p90 / max | Over 1 s | 60 sequential reads: median / p90 / max ||---|---|---|---|
| 0.7.25 | 4,751 / 11,955 / 15,546 ms | 30 | 4,181 / 10,365 / 12,163 ms |
| main | 557 / 740 / 1,043 ms | 1 | 571 / 682 / 856 ms |
| this branch | 233 / 363 / 460 ms | 0 | 187 / 284 / 575 ms |
769d2af2, two statements in a read transaction). The final single-statement lookup is faster in-process. On a copy of the same database, with no daemon and no background work, onegetEntriestakes a median of 32-34 ms (20 reps, ABBA), against 43-59 ms for769d2af2and 134-142 ms on main.includeArchived,archivedOnlyandseatsviews.What's left: on this database the idle daemon still uses most of its 28% on background sweeps (event-loop utilization about 0.95). A
psthat arrives behind one of them waits for it, which this change doesn't address.Tests
ps-resolves-each-address-once.test.ts:- one projection looks each address up once (main: 3 per address);
- a pass forgets its answers when it ends, including when it throws;
- the lookup answers as before for an exact name, a derived name, an inactive seat, an archived rig, and inside a caller's transaction;
- it answers the same inside a caller's open
iterate()cursor and on a read model that offers onlyprepare.session-address-read-plans.test.ts: checks that the lookup is one statement and readssessionsby index.-
startup.test.ts'somp/0launch case timed out once at 30 s while the box was loaded.- Alone it passes on this branch (14.6 s, 16.2 s) and on main (17.4 s).
🤖 Generated with Claude Code
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
Improvements
Rig status views and session lookups now avoid repeating address resolution and database reads during a single operation, improving efficiency when handling multiple entries.
Address-resolution behavior remains consistent across transactions, inactive seats, and archived rigs.
Repeated database queries are reused more efficiently, while address results are scoped to each read operation.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->