Skip to content

Tell the compressor which serialized IDs the writer may emit - #9770

Open
mhk197 wants to merge 5 commits into
developfrom
mk/compressor-serialized-ids
Open

Tell the compressor which serialized IDs the writer may emit#9770
mhk197 wants to merge 5 commits into
developfrom
mk/compressor-serialized-ids

Conversation

@mhk197

@mhk197 mhk197 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Filtering compression schemes by in-memory encoding cannot distinguish multiple wire formats of the same encoding. The writer now passes its permitted serialized IDs to compressor configuration, which selects the newest compatible version of each scheme before matching, generating statistics, estimating, or compressing.

Scheme::produced_encodings declares the serialized IDs that a scheme directly introduces; every declared ID must be allowed. This preserves requirements such as FSST needing both vortex.fsst and vortex.varbin. Alternative versions are represented by Scheme::predecessor: register only the newest version, fall back through its predecessor chain when its IDs are unavailable, and remove the chain when no version is eligible. Historical versions do not compete with their replacements during compression.

BtrBlocksCompressorBuilder::allow_serialized_ids replaces retain_allowed_encodings and applies restrictions at build time, including to schemes added after the restriction. Both it and CascadingCompressor::with_allowed_serialized_ids intersect repeated restrictions. Registration order is preserved, and scheme IDs in a predecessor chain resolve to the selected version for exclusions and has_scheme checks. Cycles and overlapping chains are rejected.

The default file writer uses the serialized IDs of its enabled editions, or every registered serialized ID when edition enforcement is disabled. Custom write strategies retain their own configuration. Serialization still chooses the oldest wire form the resulting array fits and validates it against the writer's allowed IDs.

Existing production schemes have no predecessors, so this prepares version selection for consumers such as bitpacking (#9754) and decimal byte parts (#9759). The related edition specification is discussed in #9779.

Tests cover version selection before estimation, required output IDs, repeated restrictions, schemes added after restrictions, registration order, exclusions across versions, invalid predecessor chains, and writer round trips with unavailable encodings.

Validation:

  • cargo check -p vortex-btrblocks --all-features: passed.
  • cargo nextest run -p vortex-compressor -p vortex-btrblocks -p vortex-file --all-features: 274 passed, 1 skipped.
  • cargo test --doc -p vortex-compressor -p vortex-btrblocks --all-features: 4 passed.
  • RUSTDOCFLAGS='-D warnings' cargo doc -p vortex-compressor -p vortex-btrblocks --all-features --no-deps: passed.
  • cargo clippy -p vortex-compressor -p vortex-btrblocks --all-targets --all-features: passed without warnings.
  • cargo +nightly fmt --all: passed.

@codspeed-hq

codspeed-hq Bot commented Sep 4, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 11.91%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚡ 2 improved benchmarks
✅ 2197 untouched benchmarks
⏩ 206 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation allocate_drop_arrow[0] 456.9 ns 402.7 ns +13.45%
Simulation allocate_drop_bytes[0] 575.7 ns 521.6 ns +10.39%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing mk/compressor-serialized-ids (94ab744) with develop (85b70cf)2

Open in CodSpeed

Footnotes

  1. 206 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on develop (5c8c397) during the generation of this report, so 85b70cf was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@mhk197 mhk197 added the changelog/chore A trivial change label Sep 4, 2026
CascadingCompressor carries the snapshot of serialized IDs the writer may emit, filled by the file writer from the enabled editions through BtrBlocksCompressorBuilder::allow_serialized_ids. A scheme whose encoding has more than one wire format picks its compression mode from it with allows_serialized_id, the newest permitted one; without a restriction every ID is allowed. No scheme consults the set yet. This is the mechanism docs/specs/editions.md describes under compression with replacement encodings (#9779).

Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Comment thread vortex-file/src/writer.rs Outdated
.with_btrblocks_builder(
BtrBlocksCompressorBuilder::default()
.retain_allowed_encodings(&allowed_array_encodings),
.retain_allowed_encodings(&allowed_array_encodings)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this has to be serialised ids

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should somehow unify these 2 functions

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can enable a scheme if at least one of associated serialized ids is enabled?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah actually I think this needs to be separate since there's a diff bw what ids MUST be allowed for a scheme to proc (all) vs what is optional (at least one).

FSST for example requires VarBin and FSST to be enabled. DBP requires at least one of v1 or v2.

Scheme::produced_encodings now names the serialized IDs a scheme may write its output under, oldest first. BtrBlocksCompressorBuilder::allow_serialized_ids replaces retain_allowed_encodings: it keeps a scheme when at least one of those IDs is permitted and hands the set to the compressor, so the writer makes one call from the serialized IDs its editions permit instead of mapping them back to in-memory encodings, which could not tell two wire formats of one encoding apart.
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
The compressor seeds each root CompressorContext with its permitted serialized IDs and every descent inherits them, so a scheme asks compress_ctx.allows_serialized_id both while estimating and while compressing and picks the same mode in both. The per-compressor accessor goes; allowed_serialized_ids remains for inspection.

Signed-off-by: Matt Katz <mhkatz97@gmail.com>
@joseph-isaacs

Copy link
Copy Markdown
Contributor

Do you have an example of this being used?

@mhk197
mhk197 force-pushed the mk/compressor-serialized-ids branch from f5b732f to c27a6d6 Compare September 8, 2026 15:10

@mhk197 mhk197 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…ed ids

Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Restore produced_encodings in feature-gated schemes and fix stale trait links. Document scheme ID resolution for Clippy.

Signed-off-by: "Matt Katz" <mhkatz97@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/chore A trivial change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants