Index: upgrade an older archive index in place instead of rescanning (SIX-196) #248

Manually merged
github merged 1 commit from gh-pr/248/head into gh-pr/248/base 2026-11-26 20:21:25 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-25 06:11 UTC · original
holdmysocks:six-196-index-upgrade → master · +613 −28 · 5 files · 1 commits · merged 2026-11-25 06:23 UTC

When INDEX_VERSION goes up, sixng index now upgrades each archive's saved index instead of rescanning the whole archive. A full rescan is kept only where the scan itself changed.

How

  • Entries are grouped again from the saved segment streams. This is cheap and covers grouping and classification changes.
  • Segments carry the scan version in their file names. A segment from scan 1 (index versions 6 and earlier) is kept as is unless scan 2 would follow stored 64 KiB chunks in it. Scan 2 only does something different at the aligned end of a stream that inflated to exactly 64 KiB when no stream starts there. At each such place raw_run is tried (a few 64 KiB reads). If it finds a run, only that 256 MiB segment is scanned again. The upgraded segment is saved under the current scan version.
  • Names of entries whose streams are unchanged are kept. Across the 7 → 8 step (name pointer), names read from a <name>.#<tag> string are recovered again. Texture dictionary names and unnamed entries stay. Only the remaining entries go through the name pass.
  • INDEX_STEPS lists every version step and what it needs (Regroup, RenameTagged or Rescan). A test fails when a version bump does not add its step. An index older than the first step is rebuilt from its segments, with every name recovered again.
  • --force still rebuilds everything.
  • sixng index reports per archive status (reused, upgraded, resumed, rescanned or new), a summary such as "upgraded from 6 (7 of 284 segments scanned)", and segment and name counts. The same line goes to the log. The viewer's Jobs page lists it per archive for an index job.

Checked on the full install

Seven archives were each built as an older version with that version's exe, upgraded with this branch, and compared field by field with a fresh --force index built by this branch (8 threads).

Archive 6 → 8 upgrade segments scanned again names kept 7 → 8 upgrade result vs fresh
levels.rpf 180 s 7 of 284 278,946 260 s (0 scanned) byte-identical (523,524 entries)
packs.rpf 20 s 3 of 18 52,525 – byte-identical
anim.rpf 3 s 1 of 17 84,343 3 s byte-identical
data.rpf 8 s 1 of 2 15,990 6 s byte-identical
textures, shaders, script ≤ 1 s each 0 – byte-identical

Before this change, the version 6 → 8 bump meant a full scan of levels.rpf (about 6 min) and then a full name pass. The version 7 exe needed 569 s on levels.rpf even with its scan 2 segments saved. The version 7 indexes differ from the fresh ones in 316 names (levels.rpf) and 40 (data.rpf), which the 7 → 8 upgrade recovers again.

Tests

scan::upgrade_tests covers:

  • the step chain ends at the current version;
  • a scan 1 segment without stored chunks is upgraded in place and matches a fresh index;
  • a scan 1 segment with stored chunks is scanned again and matches a fresh index;
  • --force and unknown versions;
  • names kept or recovered again across 7 → 8;
  • names of changed entries are dropped when regrouping;
  • the viewer's per-archive status rows.

cargo check --workspace --all-targets, cargo check --no-default-features -p sixng-cli -p sixng-gui and cargo test -p sixng-core -p sixng-gui --release pass.

**@⁠holdmysocks** on GitHub · 2026-11-25 06:11 UTC · [original](https://github.com/holdmysocks/SixNG/pull/248) `holdmysocks:six-196-index-upgrade` → `master` · +613 −28 · 5 files · 1 commits · merged 2026-11-25 06:23 UTC When `INDEX_VERSION` goes up, `sixng index` now upgrades each archive's saved index instead of rescanning the whole archive. A full rescan is kept only where the scan itself changed. ## How - **Entries** are grouped again from the saved segment streams. This is cheap and covers grouping and classification changes. - **Segments** carry the scan version in their file names. A segment from scan 1 (index versions 6 and earlier) is kept as is unless scan 2 would follow stored 64 KiB chunks in it. Scan 2 only does something different at the aligned end of a stream that inflated to exactly 64 KiB when no stream starts there. At each such place `raw_run` is tried (a few 64 KiB reads). If it finds a run, only that 256 MiB segment is scanned again. The upgraded segment is saved under the current scan version. - **Names** of entries whose streams are unchanged are kept. Across the 7 → 8 step (name pointer), names read from a `<name>.#<tag>` string are recovered again. Texture dictionary names and unnamed entries stay. Only the remaining entries go through the name pass. - `INDEX_STEPS` lists every version step and what it needs (`Regroup`, `RenameTagged` or `Rescan`). A test fails when a version bump does not add its step. An index older than the first step is rebuilt from its segments, with every name recovered again. - `--force` still rebuilds everything. - `sixng index` reports per archive `status` (`reused`, `upgraded`, `resumed`, `rescanned` or `new`), a `summary` such as "upgraded from 6 (7 of 284 segments scanned)", and segment and name counts. The same line goes to the log. The viewer's Jobs page lists it per archive for an index job. ## Checked on the full install Seven archives were each built as an older version with that version's exe, upgraded with this branch, and compared field by field with a fresh `--force` index built by this branch (8 threads). | Archive | 6 → 8 upgrade | segments scanned again | names kept | 7 → 8 upgrade | result vs fresh | |---|---|---|---|---|---| | levels.rpf | 180 s | 7 of 284 | 278,946 | 260 s (0 scanned) | byte-identical (523,524 entries) | | packs.rpf | 20 s | 3 of 18 | 52,525 | – | byte-identical | | anim.rpf | 3 s | 1 of 17 | 84,343 | 3 s | byte-identical | | data.rpf | 8 s | 1 of 2 | 15,990 | 6 s | byte-identical | | textures, shaders, script | ≤ 1 s each | 0 | | – | byte-identical | Before this change, the version 6 → 8 bump meant a full scan of `levels.rpf` (about 6 min) and then a full name pass. The version 7 exe needed 569 s on `levels.rpf` even with its scan 2 segments saved. The version 7 indexes differ from the fresh ones in 316 names (`levels.rpf`) and 40 (`data.rpf`), which the 7 → 8 upgrade recovers again. ## Tests `scan::upgrade_tests` covers: - the step chain ends at the current version; - a scan 1 segment without stored chunks is upgraded in place and matches a fresh index; - a scan 1 segment with stored chunks is scanned again and matches a fresh index; - `--force` and unknown versions; - names kept or recovered again across 7 → 8; - names of changed entries are dropped when regrouping; - the viewer's per-archive status rows. `cargo check --workspace --all-targets`, `cargo check --no-default-features -p sixng-cli -p sixng-gui` and `cargo test -p sixng-core -p sixng-gui --release` pass.
`sixng index` no longer rescans a whole archive when INDEX_VERSION goes up.
Entries are grouped again from the saved segments, and a segment from the
scan before index version 7 is kept unless scan 2 would follow stored 64 KiB
chunks in it (checked with a few reads where a full chunk is not followed by
a stream); only those segments are scanned again. Names of unchanged entries
are kept; across the 7 -> 8 step, names read from a "<name>.#<tag>" string
are recovered again. Each version step is listed in INDEX_STEPS with what it
needs, and a test fails when a bump does not add one. --force still rebuilds
everything.

`sixng index` reports per archive whether the index was reused, upgraded,
resumed, rescanned or new (and how many segments were scanned); the viewer's
Jobs page lists the same for an index job.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:21:23 +00:00
github manually merged commit 6c8e48fd0f into gh-pr/248/base 2026-11-26 20:21:25 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.