GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — perf(server): history compaction drops ~90% of provider-turn updates by t3dotgg · Pull Request #22548 · pingdotgg/t3code

Conversation

@t3dotgg

@t3dotgg t3dotgg commented Oct 20, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Server updates on a big install are slow, and the database size drives it. On one Linux box, statev2.sqlite is 12.7 GB. Each update makes a full copy of it before the new server starts, and the server is down during the copy.

This PR is one easy win from looking into it. Compaction now also drops superseded provider-turn.updated events. Below that are the findings for the rest.

The change

Provider turns get an update for every token usage report, about 36 per turn. Compaction already drops superseded updates for nodes and messages, but it kept every provider-turn update. Now it keeps three per turn:

  • the first update, because client reducers append an entity where they first see it
  • the newest update
  • the newest update that carries tokenUsage, because updates without usage inherit it from earlier ones (upsertProviderTurn and the client reducer both do this)

run.updated and provider-thread.updated stay as they are. CodexUsageHistory reads intermediate run.updated events, and provider-thread.updated moves rows between threads.

Measured with this branch's DatabaseMaintenance.compact on a clone of the real database: 11.56 GiB → 10.27 GiB (−11%). It removed 291,936 events, and provider-turn.updated dropped from 317,681 to 25,761. Projections verified as valid before and after. For comparison, the existing doctor compact had just taken the same database from 11.97 to 11.56 GiB. This also stops the fastest-growing compactable event type from piling up.

Findings: what a 37s update spends its time on

Timeline from boot-service.log and the server traces, for an update with a 6 ms migration:

Step Time
Download, tar, version check (server still up) 5.7s
Handoff delay, then old server shutdown ~6s
Launcher copies the database (cp --reflink=auto on ext4 falls back to a full copy, then fsync) 29.5s
Migration 28 ms
New server listening, then tunnel reachable +13s
Desktop client over T3 Connect sends its first request +26s after listening

What is in the 12.7 GB:

Table or index Size
orchestration_events 7.1 GB (1.68M rows)
event indexes 1.6 GB
projection_turn_items 1.9 GB
projection_nodes 0.96 GB

Events by type:

Event type Events Entities
turn-item.updated 696k 336k
node.updated 433k 242k
provider-turn.updated 316k 8.6k
provider-thread.updated 68k 609

Things that do not help much:

  • VACUUM: shrinks the snapshot only from 12.78 to 12.33 GB. dbstat reports 3.15 GB as unused, but most of it is page slack, not free pages: event rows are 3–4 KB on 4 KB pages. A rebuild with 16 KB pages brings it to 10.51 GB. That is a possible follow-up for t3 doctor or for new databases, but it needs its own performance check.
  • Turn items: these are real history, about 2 updates per item. Most of the bytes are command_execution (1.0 GB) and reasoning (0.56 GB).

Follow-ups this PR does not cover:

  • Launcher version: the systemd unit runs the launcher from the runtime it was installed with (0.0.46, 17 days old). Launcher fixes never reach that machine. See #19652.
  • Backup during downtime: the copy happens while the server is down, and nothing logs it. #18633 adds progress reporting but keeps the cost. Copying while the old server still runs, then copying only the WAL file during downtime, would remove most of the outage on filesystems without reflink.
  • Reconnect delay: client backoff doubles to 16–32s within a 30s outage. Only the client that starts the update nudges every 1s, so other devices can wait up to about 30s after the server is back. The server sends no "restarting for update" signal clients could act on. The 26s gap above needs client-side logs to fully explain.

Created with Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@t3dotgg @claude
perf(server): compaction drops superseded provider-turn updates
ee6017c
Provider turns emit an update for every token usage report, about 36 per
turn, and compaction kept all of them. Compact them like nodes and
messages: keep the first and newest update per turn, plus the newest
update that carries token usage, since later updates without usage
inherit it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Oct 20, 2026
@juliusmarminge juliusmarminge added the macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews label Oct 20, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs Human Approval

Macroscope's review found this PR requires human approval — This server change substantially alters automatic history compaction by deleting most previously retained provider-turn updates, while preserving selected state and token usage. Because the effect is production-facing and irreversible, it warrants review beyond the added test coverage.

You can add or adjust custom eligibility rules. Learn more.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 20.9 KiB 20.9 KiB 0 B (0.0%) 29.3 KiB ✅
Codex Live turn messages 2 2 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅
Claude Live turn messages 2 2 0 (0.0%) 8 ✅

Baseline: 5d27ecd · PR result: ee6017c · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Team
  • Run ID: da85fd38-8740-41d8-8961-ba92fd663774
📥 Commits

Reviewing files that changed from the base of the PR and between 5d27ecd and ee6017c.

📒 Files selected for processing: 2
  • apps/server/src/orchestration-v2/FoundationPersistence.test.ts
  • apps/server/src/orchestration-v2/ProjectionMaintenance.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

📝 Walkthrough

Event-store compaction now includes provider-turn updates. It retains the oldest provider-turn event and the newest event that includes token usage. The compaction test covers these retention rules.

Changes: Provider-turn compaction

Layer / File(s) Summary
Provider-turn retention rules
apps/server/src/orchestration-v2/ProjectionMaintenance.ts
Compaction extracts provider-turn keys and identifies updates with tokenUsage. It retains the newest usage-bearing event along with the oldest event.
Retention test coverage
apps/server/src/orchestration-v2/FoundationPersistence.test.ts
The compaction scenario adds provider-turn events with and without token usage. Assertions check the retained event ordering and deletion count.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Feature

Suggested reviewers: juliusmarminge

Merge Risk: ⚪ Minimal · up to ee601

Provider-turn compaction preserves the inspected replay behavior, and no actionable issue remains before merge.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description clearly explains the problem, the provider-turn compaction change, measured results, verification evidence, out-of-scope follow-ups, and the agent used. It does not include the require… Add a ## Scope and approval section. Link the triaged issue or discussion with explicit maintainer approval and the approval comment. If no prior approval is required, explain why this is a small, focused fix of an obvious bug and state h…
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title is concise, conventional, and accurately describes the main change: reducing provider-turn updates during server history compaction.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description clearly explains the problem, the provider-turn compaction change, measured results, verification evidence, out-of-scope follow-ups, and the agent used. It does not include the required Scope and approval section or provide a triaged issue, maintainer approval, or an explanation for why this focused fix is exempt.

Resolution

Add a ## Scope and approval section. Link the triaged issue or discussion with explicit maintainer approval and the approval comment. If no prior approval is required, explain why this is a small, focused fix of an obvious bug and state how its scope remains limited.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@t3dotgg t3dotgg mentioned this pull request Oct 21, 2026
perf(server): database shrinks ~64% by pruning thread history older than a day #22630
Closed
This was referenced Oct 21, 2026
[Bug]: Intermediate turn-item snapshots remain outside event compaction (78.5 MB on one install) #19780
Closed
fix(server): long streams no longer store a full copy per paragraph #24700
Closed
@JustYannicc JustYannicc mentioned this pull request Oct 31, 2026
fix(server): compact superseded provider-turn updates #28109
Closed
@JustYannicc

JustYannicc commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

A rebased port is ready at #28109, with credit to this implementation. It also keeps command-associated provider-turn snapshots for command-result replay. On an isolated 95-thread subset, provider-turn events fell from 9,704 to 2,357 and all thread projections matched before and after rebuild. Maintainers can choose either PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JustYannicc JustYannicc mentioned this pull request Oct 31, 2026
orchestration_events grows without bound: streaming updates are stored as permanent events and never compacted #21154
Closed
@juliusmarminge GitCafe Production

juliusmarminge commented Nov 9, 2026

Copy link
Copy Markdown
Member

Thanks, Theo, for investigating and implementing this. #29806 (550c5fa34b) now prunes old provider-turn updates along with other projection-covered events, addressing the same database growth. It deliberately retains at least a day of history rather than compacting the recent tail. If reducing that recent tail still matters, please propose it separately against the new retention model.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@juliusmarminge juliusmarminge closed this Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews size:M 30-99 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@t3dotgg @JustYannicc @juliusmarminge
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.