Skip to content

feat(engine): wire SpillGranularity.PerItem in spill write path (STN-5 #2339) - #4428

Merged
oferchen merged 1 commit into
masterfrom
feature/stn-5-granularity-wiring
May 18, 2026
Merged

oferchen merged 1 commit into
masterfrom
feature/stn-5-granularity-wiring

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • SpillGranularity::WholeBatch (default) now packs every candidate selected by a single spill event into one length-prefixed record so the 4-byte header is amortised across many items.
  • SpillGranularity::PerItem preserves the historical one-record-per-item layout for callers that want a single reload to decode only one payload.
  • ConcurrentDeltaConfig::spill_policy.granularity is wired through DeltaConsumer::spawn_with_config so the policy knob is no longer a forward-compat stub.

On-disk format

Each record is [u32 len LE][payload bytes]. The len field is u32 little-endian to match the existing per-item layout; nothing else on disk changes for PerItem. For WholeBatch the payload simply concatenates every SpillCodec::encode output for the candidates selected in the same spill event, and the reload path decodes them sequentially using the self-delimiting codec contract.

Test plan

  • cargo fmt --all clean
  • granularity_whole_batch_writes_single_chunk - default path writes one length-prefix per spill event
  • granularity_per_item_writes_n_chunks - alternative path writes one length-prefix per item
  • granularity_per_item_round_trip_byte_identical and matching whole-batch round-trip pin payload integrity across both formats

Closes #2339.

@github-actions github-actions Bot added the enhancement New feature or request label May 18, 2026
@oferchen
oferchen force-pushed the feature/stn-5-granularity-wiring branch from 0801bcc to 596ab5d Compare May 18, 2026 00:55
…#2339)

The `SpillGranularity` knob on `SpillPolicy` was a forward-compat stub.
This change makes `SpillableReorderBuffer` honour the field at write
time and wires it through `ConcurrentDeltaConfig` so callers can
actually pick a strategy:

- `WholeBatch` (default): one length-prefixed record per spill event
  holds every non-hot-zone candidate concatenated. The 4-byte header is
  paid once per event instead of once per item, and reload decodes the
  whole record and refills the in-memory ring.
- `PerItem`: keeps the historical layout of one record per item, so a
  single reload only has to decode one payload.

`spill_index` keeps mapping sequence -> record offset for both flavours.
A new `batch_members` map records the encode-order sibling sequences
for whole-batch records so partial evictions survive without corrupting
decode order; per-item records skip the map entirely.

Three new unit tests cover the contract: `granularity_whole_batch_writes_single_chunk`
asserts on-disk size equals `header_bytes + payload_bytes` with a single
header per event; `granularity_per_item_writes_n_chunks` asserts the
per-item layout pays one header per item; `granularity_per_item_round_trip_byte_identical`
plus a matching whole-batch test pin payload integrity across both
formats.

Closes #2339.
@oferchen
oferchen force-pushed the feature/stn-5-granularity-wiring branch from 596ab5d to c6a0807 Compare May 18, 2026 01:13
@oferchen
oferchen merged commit 97132cd into master May 18, 2026
4 of 15 checks passed
oferchen added a commit that referenced this pull request May 18, 2026
…#2339) (#4428)

The `SpillGranularity` knob on `SpillPolicy` was a forward-compat stub.
This change makes `SpillableReorderBuffer` honour the field at write
time and wires it through `ConcurrentDeltaConfig` so callers can
actually pick a strategy:

- `WholeBatch` (default): one length-prefixed record per spill event
  holds every non-hot-zone candidate concatenated. The 4-byte header is
  paid once per event instead of once per item, and reload decodes the
  whole record and refills the in-memory ring.
- `PerItem`: keeps the historical layout of one record per item, so a
  single reload only has to decode one payload.

`spill_index` keeps mapping sequence -> record offset for both flavours.
A new `batch_members` map records the encode-order sibling sequences
for whole-batch records so partial evictions survive without corrupting
decode order; per-item records skip the map entirely.

Three new unit tests cover the contract: `granularity_whole_batch_writes_single_chunk`
asserts on-disk size equals `header_bytes + payload_bytes` with a single
header per event; `granularity_per_item_writes_n_chunks` asserts the
per-item layout pays one header per item; `granularity_per_item_round_trip_byte_identical`
plus a matching whole-batch test pin payload integrity across both
formats.

Closes #2339.
oferchen added a commit that referenced this pull request May 18, 2026
…#2339) (#4428)

The `SpillGranularity` knob on `SpillPolicy` was a forward-compat stub.
This change makes `SpillableReorderBuffer` honour the field at write
time and wires it through `ConcurrentDeltaConfig` so callers can
actually pick a strategy:

- `WholeBatch` (default): one length-prefixed record per spill event
  holds every non-hot-zone candidate concatenated. The 4-byte header is
  paid once per event instead of once per item, and reload decodes the
  whole record and refills the in-memory ring.
- `PerItem`: keeps the historical layout of one record per item, so a
  single reload only has to decode one payload.

`spill_index` keeps mapping sequence -> record offset for both flavours.
A new `batch_members` map records the encode-order sibling sequences
for whole-batch records so partial evictions survive without corrupting
decode order; per-item records skip the map entirely.

Three new unit tests cover the contract: `granularity_whole_batch_writes_single_chunk`
asserts on-disk size equals `header_bytes + payload_bytes` with a single
header per event; `granularity_per_item_writes_n_chunks` asserts the
per-item layout pays one header per item; `granularity_per_item_round_trip_byte_identical`
plus a matching whole-batch test pin payload integrity across both
formats.

Closes #2339.
@oferchen
oferchen deleted the feature/stn-5-granularity-wiring branch May 19, 2026 15:10
oferchen added a commit that referenced this pull request Jun 16, 2026
…ignore (#5842)

* fix(filters): parse :C modifier on per-directory merge rules for CVS-ignore

When a per-directory merge rule uses the `:C` (or `.C`) short form with
an empty pattern, the parser rejected it as "unrecognized filter rule"
instead of defaulting the filename to `.cvsignore`, and the `C`
(CVS-ignore) modifier was never propagated from `RuleModifiers` onto the
resulting `FilterRule`. The wire-format path and the CLI `--filter :C`
path already handle this correctly; only merge files read from disk via
`parse_rules` (e.g. `mid/.filt`) were affected. This breaks the upstream
`merge` and `exclude-lsh` testsuite scenarios (task #4428, UTS-V4.B).

Add a `cvs_mode` flag to `FilterRule` with a `with_cvs_mode` builder and
`is_cvs_mode` accessor; propagate it through `RuleModifiers::apply`; and
in `try_parse_short_form`, when a `:`/`.` rule has empty pattern and the
`C` modifier set, default to the filename `.cvsignore`.

upstream references (rsync-3.4.4):
  - exclude.c:1248-1255: `:C` sets FILTRULE_NO_PREFIXES |
    FILTRULE_WORD_SPLIT | FILTRULE_NO_INHERIT | FILTRULE_CVS_IGNORE.
  - exclude.c:1324: empty pattern only errors when FILTRULE_CVS_IGNORE
    is unset.
  - exclude.c:1404-1408: empty-pattern merge defaults to `.cvsignore`.
  - testsuite/merge.test, testsuite/exclude-lsh.test:86-88: failing
    fixtures.

* fix(filters): backfill cvs_mode in FilterRule struct literals

The :C modifier work added a cvs_mode field to FilterRule but missed
the test-side struct literal initializations in crates/filters/src/
compiled/{clear,mod,rule}.rs. The build now fails with E0063 because
those literals omit the new field.

Add cvs_mode: false to every FilterRule struct literal in those test
modules so the field set matches the public struct definition.
oferchen added a commit that referenced this pull request Aug 24, 2026
…#2339) (#4428)

The `SpillGranularity` knob on `SpillPolicy` was a forward-compat stub.
This change makes `SpillableReorderBuffer` honour the field at write
time and wires it through `ConcurrentDeltaConfig` so callers can
actually pick a strategy:

- `WholeBatch` (default): one length-prefixed record per spill event
  holds every non-hot-zone candidate concatenated. The 4-byte header is
  paid once per event instead of once per item, and reload decodes the
  whole record and refills the in-memory ring.
- `PerItem`: keeps the historical layout of one record per item, so a
  single reload only has to decode one payload.

`spill_index` keeps mapping sequence -> record offset for both flavours.
A new `batch_members` map records the encode-order sibling sequences
for whole-batch records so partial evictions survive without corrupting
decode order; per-item records skip the map entirely.

Three new unit tests cover the contract: `granularity_whole_batch_writes_single_chunk`
asserts on-disk size equals `header_bytes + payload_bytes` with a single
header per event; `granularity_per_item_writes_n_chunks` asserts the
per-item layout pays one header per item; `granularity_per_item_round_trip_byte_identical`
plus a matching whole-batch test pin payload integrity across both
formats.

Closes #2339.
oferchen added a commit that referenced this pull request Aug 24, 2026
…ignore (#5842)

* fix(filters): parse :C modifier on per-directory merge rules for CVS-ignore

When a per-directory merge rule uses the `:C` (or `.C`) short form with
an empty pattern, the parser rejected it as "unrecognized filter rule"
instead of defaulting the filename to `.cvsignore`, and the `C`
(CVS-ignore) modifier was never propagated from `RuleModifiers` onto the
resulting `FilterRule`. The wire-format path and the CLI `--filter :C`
path already handle this correctly; only merge files read from disk via
`parse_rules` (e.g. `mid/.filt`) were affected. This breaks the upstream
`merge` and `exclude-lsh` testsuite scenarios (task #4428, UTS-V4.B).

Add a `cvs_mode` flag to `FilterRule` with a `with_cvs_mode` builder and
`is_cvs_mode` accessor; propagate it through `RuleModifiers::apply`; and
in `try_parse_short_form`, when a `:`/`.` rule has empty pattern and the
`C` modifier set, default to the filename `.cvsignore`.

upstream references (rsync-3.4.4):
  - exclude.c:1248-1255: `:C` sets FILTRULE_NO_PREFIXES |
    FILTRULE_WORD_SPLIT | FILTRULE_NO_INHERIT | FILTRULE_CVS_IGNORE.
  - exclude.c:1324: empty pattern only errors when FILTRULE_CVS_IGNORE
    is unset.
  - exclude.c:1404-1408: empty-pattern merge defaults to `.cvsignore`.
  - testsuite/merge.test, testsuite/exclude-lsh.test:86-88: failing
    fixtures.

* fix(filters): backfill cvs_mode in FilterRule struct literals

The :C modifier work added a cvs_mode field to FilterRule but missed
the test-side struct literal initializations in crates/filters/src/
compiled/{clear,mod,rule}.rs. The build now fails with E0063 because
those literals omit the new field.

Add cvs_mode: false to every FilterRule struct literal in those test
modules so the field set matches the public struct definition.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant