Repository navigation
perf(audit): reduce shared writer waits during retention pruning - #176797
Merged
steipete merged 2 commits intoOct 19, 2026
Merged
Conversation
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
steipete
marked this pull request as ready for review
October 19, 2026 02:10
Contributor
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Replace retained-ID materialization with indexed tuple cutoffs while preserving expiry budgets and oldest-first retention. Add focused compatibility cases and a synthetic shared-writer benchmark.
steipete
force-pushed
the
steipete/perf-micro-channel-ingress-writer-wait-20260919
branch
from
October 19, 2026 02:19
ebd3f25 to
296419a
Compare
steipete
deleted the
steipete/perf-micro-channel-ingress-writer-wait-20260919
branch
October 19, 2026 02:27
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 19, 2026
…nclaw#176797) * perf(audit): reduce shared writer waits during retention pruning Replace retained-ID materialization with indexed tuple cutoffs while preserving expiry budgets and oldest-first retention. Add focused compatibility cases and a synthetic shared-writer benchmark. * fix(bench): preserve the writer error array type
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 19, 2026
Register the documented maintainer CLI from openclaw#176797 using the existing executable entry pattern. Remove the unused fixture left by openclaw#176648 after its diagnostic suite reductions were dropped; keep the original diagnostic tests intact.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Reduces inbound-message and interactive-write delays when enabled execution-identity audit storage reaches its retention caps and competes for the shared SQLite writer.
User Impact
Audit-heavy installations spend less time holding the writer, so channel ingress and interactive state writes can proceed sooner. Retention membership, oldest-first deletion, expiry budgets, transaction boundaries, FIFO ordering, and ingress dedupe/durability remain unchanged. No schema, configuration, or migration change is required.
Why This Change Was Made
Each identity/decision insertion previously materialized up to 100,000/250,000 retained IDs for an overflow
NOT INquery. The replacement finds the first overflow(timestamp, id)through the existing ordered index, then deletes the oldest eligible rows within the remaining expiry-cleanup budget. It still derives the boundary from database state inside the same transaction.The shared writer remains the sole owner. Existing ingress batching is retained; another worker would still contend for the same SQLite database. This removes retained-set construction instead of introducing another queue, cache, or priority policy. Runtime production delta is +4 lines (14 added, 10 removed): the typed tuple cutoff needs an offset, a one-row limit, and tuple typing to preserve exact bounded retention. The rest is two compatibility cases (+59 test lines), documentation, and a rerunnable synthetic benchmark. The requested diff filter excluding tests and
docs/*totals +522 lines: +4 runtime, +495 benchmark, and +23 benchmark README. The benchmark growth supplies the requested reproducible concurrent-writer workload and persistence/dedupe checks; it adds no product runtime state.Evidence
Acceptance was recorded before measurement: preserve every accepted audit/ingress/interactive operation and bounded retention; reduce audit service time and ingress queue wait without an interactive p99 regression. The benchmark drives the real audit FIFO, channel-ingress queue, and machine-state writer with 100,000 retained contexts and 250,000 retained decisions. Each 60-second run offers 180 audit records (90 identities/90 decisions), 60 ingress messages, 12 duplicate attempts, 60 idle-drain polls, and 60 interactive writes.
Four concurrent A/B pairs completed on an isolated Linux sandbox, swapping 16-core CPU halves for each successive pair under one exclusive measurement lock. A is main
8a23c56a8338; B differs only in the two retention queries. Fixtures were seeded sequentially with the same timestamp and sizes; separate databases were reused across pairs, retaining the same caps. The branch was subsequently rebased onto latest main without conflicts; the audit/ingress/state paths were unchanged by that refresh.Results below are medians across the four runs. Decisions use each pair's B minus A difference, not the difference between unpaired medians.
The improvement is reduced audit service time and contention on other request classes; audit's own queue wait is neutral (+7 ms/min median paired difference). Pair 3 retained a shared ~590 ms interactive tail stall on both sides rather than discarding it. Interactive p50 is roughly neutral overall; pair 2 moved from 2.0 to 5.4 ms while its p95/p99 improved, reflecting the phase-sensitive contention at these low rates.
mpstat -P 96-127recorded mean CPU occupancy for the two halves (including the experiment): 10.5%/9.0%, 7.2%/7.6%, 13.5%/12.0%, and 4.6%/5.6% across pairs 1–4. This is context, not an invalidation threshold. Both sides ran concurrently at the same offered start time.All eight processes exited successfully, all submitted audit records persisted, duplicate attempts retained one ingress tombstone, no ingress/writer work remained unsettled, and no diagnostic samples were dropped. Row counts stayed at the existing caps.
Reproduction (run each side from its source tree with separate synthetic state):
Prepare outside measurement, then run both sides concurrently with
systemd-run --scope -p AllowedCPUs=96-111/112-127, swapping halves for the next pair. Seescripts/perf/README.mdfor workload details.Validation: 31 focused tests passed across
execution-identity-context.test.ts,execution-decision-facts.test.ts, andaudit-event-writer.worker.test.ts; changed-file oxfmt/lint and the singlepnpm tsgo:corelane passed. The export-collision guard and 22 tests acrosseager-import-closure.test.ts/pr-wrapper-source-closure.test.tsalso passed. Independent isolated Codex review was scoped-clean with no actionable P0–P2 findings. PR CI supplies broad validation; no Testbox/Crabbox lease was used.Limits: this is storage-owner evidence, not Gateway transport, external-channel, model, or deployment end-to-end proof. It intentionally stresses opt-in identity/decision storage at retention caps; it does not establish current production table sizes, ordinary run/tool-only audit mix, or the fraction of reported production queue delay this change removes. The added tests protect retention equivalence; performance evidence comes from the benchmark, not a timing assertion in unit tests.
CI follow-through: initial run 39188739353 found one benchmark-only TS2345:
assert.deepEqual(errors, [])narrowed the error accumulator tonever[]. The follow-up uses length assertions with error diagnostics, preserving the measured workload, and received a fresh clean independent review. All selected audit/changed-code test shards, lint, docs, and architecture guards passed on that run.The remaining initial-run failures share an inherited Control UI import mismatch introduced by #176453. Unchanged main
d79b0a4df0b24fd1e630e22da22cc2bb40af45cereproduces the identicalSidebarProjectionMemomissing export in UI build job 117857506284, and TS2724/TS7006 in production-types job 117857507285.session-attention.tsandsidebar-projection-memo.tsare byte-identical on that main baseline and this PR; no UI files are changed here. These errors also propagate to the core test-type stripes and build-artifact workflow. No CI jobs were rerun to chase green.The repaired head
296419aeacee94456faa2528cc4c80716d589a8dpassescheck-test-typesin CI run 39189406757, including the benchmark script typecheck.