Skip to content

perf(decoding): mirror donor ddictIsCold signal for pipelined dispatch #273

Description

@polaz

Problem

Donor `ZSTD_decompressBlock_internal` initialises `usePrefetchDecoder` from `dctx->ddictIsCold` so the first block of a freshly-attached-dict frame engages the prefetch decoder unconditionally, then clears the flag for subsequent blocks. Our seq-decoder dispatch gate currently reads ONLY `fse.offsets_long_share >= MIN_LONG_OFFSET_SHARE` and explicitly calls out the missing cold-dict signal in a comment (sequence_section_decoder.rs:408-413).

Consequence: dict-attached frames whose first block has low long-offset share never engage the prefetch path, even though the FSE/HUF tables are still cold in cache from the dict attach.

Solution

Add the missing signal:

  • `FSEScratch.ddict_is_cold: bool` (default false)
  • `DecoderScratch::init_from_dict` sets it to true (mirrors donor's `ZSTD_decompressBegin_usingDDict`)
  • `decode_and_execute_sequences_impl` reads + clears the flag on every entry, ORs into the `use_long_pipeline` gate
  • After the first block consumes the flag, subsequent blocks fall back to the existing `offsets_long_share` heuristic

Acceptance criteria

  • FSEScratch.ddict_is_cold field added
  • init_from_dict sets it
  • Seq decoder reads + clears + ORs into gate
  • Unit test on the flag set-on-init transition
  • No regression: full test suite (default + lsm) green

Time estimate

1h (small surface, clear donor parity target)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2-mediumMedium priority — important improvementenhancementNew feature or requestperformancePerformance optimization

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions