Skip to content

chore: Incremental account codes pruning - #2463

Open
sergerad wants to merge 1 commit into
nextfrom
sergerad-account-codes-prune-perf
Open

chore: Incremental account codes pruning#2463
sergerad wants to merge 1 commit into
nextfrom
sergerad-account-codes-prune-perf

Conversation

@sergerad

@sergerad sergerad commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #2444.

The vault and storage prunes are incremental: each block only visits rows that expired since the previous prune. The account-code prune instead re-scanned every account row still valid past the cutoff on every block.

This PR makes the codes prune churn-driven. A code pinned at one prune can only become collectable at a later one if its last referencing row expired between the two cutoffs, so the prune scans just that window for candidates and probes each for a surviving reference — O(churn) per block, like the other two prunes.

Implementation notes:

  • Migration 005 adds idx_accounts_code_probe (backs the existence probe) and a single-row prune_progress table recording the cutoff through which code pruning has completed. The marker is updated in the same transaction as the prune, so it is crash-consistent and survives restarts.
  • With no marker recorded (first prune after migration, or a fresh database), the previous full-pass query runs once.
  • When the cutoff hasn't advanced (e.g. stalled prune_tip), the prune now skips entirely instead of re-scanning the live set.

Changelog

changelog = "none"
reason    = "Internal change only."

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.

Improve account code pruning performance

1 participant