Skip to content

[PR] perf(storage): use a point lookup for session removal - #6615

Merged
ranxianglei merged 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-13_point-session-removal
Nov 14, 2026
Merged

ranxianglei merged 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-13_point-session-removal

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Fixes #6613.

Deleting one session currently materializes the whole session catalog to obtain that session's protocol and origin. The catalog query also calculates two block aggregates and parses statistics JSON for every session. Repeating the maintenance operation repeats that unrelated work.

Read the two identity columns directly through the existing sessions.session_id key. The shadow wrapper retains its null result on an async-only backend. The existing error fallback, envelope metadata precedence, row-existence check, cascade/CAS deletion and session-file discovery stay in their original order.

Measured effect

Seven alternating fresh-process pairs per workload on Node 24.22.1, using the real SQLite store and complete sequential SessionStore.removeSession operations. Each process starts from a copy of the same seeded database and performs one separate warmup deletion. Setup, database open, output verification and teardown are outside the timer.

Workload Baseline median wall time Candidate median wall time Baseline / candidate median CPU
5,000 stored sessions, 100 deletions 1,865.67 ms 102.46 ms 1,905.01 / 110.13 ms
16 stored sessions, 8 deletions 8.73 ms 10.66 ms 10.85 / 12.51 ms

All seven large-catalog pairs improve (9.59–18.59x). The small control is mixed and its median is slower; no small-store benefit or general request-latency improvement is claimed. These fixtures use DB-only sessions with two stored messages each and no compression blocks. Legacy-file search, cascades and CAS refcount release are included in the measured operation.

Every baseline/candidate process has the same input-file hash and resulting logical hash over all database tables for its workload. The large workload leaves exactly 4,899 sessions and 9,798 messages/content rows after the warmup plus measured deletions. The benchmark driver is included:

node --import ./tests/preload-test-env.mjs --import tsx scripts/bench-session-removal.ts seed /path/to/fixture 5000
node --import ./tests/preload-test-env.mjs --import tsx scripts/bench-session-removal.ts run /path/to/fixture 100

Run the second command against both revisions with the same fixture directory. Use a new empty directory when seeding a fixture.

Validation

  • Eight real SQLite/file compatibility controls pass on both the unmodified base and candidate: four protocol/unknown-identity dual-write cases, DB-only deletion with shared-content preservation, an absent index row with surviving files, corrupt-envelope quarantine, and a missing target with an unrelated survivor.
  • New controls plus existing maintenance and archive/GC suites: 20 passed on both revisions.
  • Typecheck, complete build, unused-export guard, test-import-graph guard and git diff --check pass.
  • Independent review checked field/null mapping, unavailable-backend fallback and deletion ordering.

Scope

No configuration, persistence format/version, wire behavior or kernel changes. No new network-backend behavior: this synchronous lookup previously returned no catalog rows for async-only backends and still degrades to the existing file path. Current-head remote CI remains a separate check after publication.

@ranxianglei ranxianglei changed the title perf(storage): use a point lookup for session removal [PR] perf(storage): use a point lookup for session removal Nov 13, 2026
@ranxianglei
ranxianglei merged commit 179397b into ranxianglei:master Nov 14, 2026
46 of 50 checks passed
@ranxianglei

Copy link
Copy Markdown
Owner

Superseded by #6677 (merged as 3858b6956, 2026-11-14).

Landed into master via the real merge commit 179397be6a1 (Merge Afloat16/2026-11-13_point-session-removal (PR #6615)), so your original commits are preserved verbatim in master history — only hashes of the batch wrapper changed, your authorship and commit messages are intact.

The fix for #6613 is now in master. Closing this PR as superseded — thanks for the careful, well-tested fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Single-session removal materializes the entire session catalog for two identity fields

2 participants