You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
controlapi, atepg: cut per-operation PostgreSQL lease writes on ResumeActor and SuspendActor #3977
A cold resume + suspend cycle makes 8 write commits in PostgreSQL. Half of them (4 of 8) are lease writes (AcquireLease and ReleaseLease on the leases table). Each write waits for a log flush, which caps size10 near 7,450 cycles/s.
Today we also write to the leases table even when a call has nothing to do:
Calling ResumeActor when the actor is already RESUMING: Before taking the lease, ResumeActor only returns early if the actor is RUNNING. While an actor is RESUMING (for example, when atenet-router polls every 250 ms), every poll still writes to leases and fails with a conflict.
Calling SuspendActor when the actor is already SUSPENDED or SUSPENDING:SuspendActor takes and deletes a database lease before reading the actor's state at all.
Normal wake and suspend cycles: Every resume and suspend inserts and deletes a lease row, even though actors updates already check the row version.
What to do
Skip the lease on no-op and in-flight calls: Read the actor before taking the lease in ResumeActor, SuspendActor, and ReportSnapshotStatus. Return early without touching leases when the actor is already in the target state, in a terminal state, or actively RESUMING / SUSPENDING.
Cut lease writes on normal cycles: Explore replacing per-call leases rows with versioned state claims on actors (or in-memory fencing). That cuts cycle writes from 8 toward 4.
Measure the gain: Check pg_commits per cycle, peak cycles/s (>= 10,000/s goal on size10), and P90 wake latency on benchmarking/isolate.
Activity