Skip to content

perf(decode): batched refill + multi-literal decode inside the fastloop (revisit #2630/#2669) #2800

Description

@kim-em

Revisit batched bit-refill and multi-literal-per-refill decoding inside the fastloop, now that the two prior negative results (#2630, #2669) have had their premises removed. Strictly sequenced after the packed length/distance entries and the fastloop split.

Why the prior negatives no longer apply

Both earlier attempts measured the right change on the wrong shape, and both post-mortems said so explicitly:

After the fastloop split removes the per-refill input bounds check, and the packed length/distance entries make the fast-literal test a single bit test, the premises flip:

  • refill once per iteration with one 8-byte wide load (k≈7 now, not 1), then
  • decode 2-3 literals, or a literal + a full match, from the ~56 buffered bits — libdeflate does up to 3 literals per refill with next-entry preloading; miniz does 1 refill per 2 literals.

Method

Keep the same-worktree A/B discipline from #2630 (a cross-worktree baseline once produced a 37-point phantom). Spike with the equivalence sorry'd. If, even on the restructured loop, our codegen still measures this neutral, close it with the measurement — the fastloop-split gains are retained regardless.

Dependencies

Hard: requires the packed length/distance entries (single-bit literal test) and the fastloop/slowloop margin split (no per-refill input check) to be in place first.

🤖 Prepared with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttrack-dBenchmarking and verified optimization (PLAN.md Track D)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions