Skip to content

Work - #4

Merged
apostasie merged 3 commits into
mainfrom
work
Aug 16, 2026
Merged

Work#4
apostasie merged 3 commits into
mainfrom
work

Conversation

@apostasie

Copy link
Copy Markdown

No description provided.

apostasie and others added 3 commits August 15, 2026 21:09
  The parallel reader positions each worker by the stream index, so a
  block area that begins with the index indicator (0x00) means the index
  and the block area disagree — corruption. decodeBlock returned the bare
  errIndexIndicator sentinel unwrapped, which matches neither ErrCorrupt
  nor anything else a caller could act on; the same class of gap the
  block-header padding fix closed.

  The sentinel keeps its meaning in the sequential reader, where reaching
  the index indicator is how the block loop legitimately ends; only the
  parallel site, where the index has already promised a block, wraps it
  as ErrCorrupt.

  The test plants 0x00 at the first block's offset and asserts both
  readers reject the input and the parallel error matches ErrCorrupt; it
  fails on the previous code with the exact message observed.

Signed-off-by: apostasie <spam_blackhole@farcloser.world>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: apostasie <spam_blackhole@farcloser.world>
  The classic-format decoder pulls compressed bytes one at a time through
  an io.ByteReader. NewReader used the input directly when it already was
  one, and otherwise wrapped it in breader — a one-byte Read per byte, by
  design, so the reader would never consume past the stream. On an
  *os.File that is one system call per compressed byte: 7 MB/s against
  84 MB/s for the same file behind a bufio.Reader, an 11.6× penalty for
  the most natural possible call, NewReader(f). The repo's own gxz CLI
  quietly avoided it by wrapping its files in bufio first.

  Wrap a plain reader in bufio.NewReader inside NewReader. An input that
  is already an io.ByteReader — bufio.Reader, bytes.Reader, strings.Reader
  — is left alone, so its exact position stays under the caller's control
  and nothing changes for it. The trade is documented on Reader: the
  wrapper may read past the stream's end, and a caller who needs the
  input positioned exactly there passes a ByteReader of its own.

  TestReaderInputConsumption pins both halves: a ByteReader input is
  consumed exactly to the end of the stream (this passed on the previous
  code too — the exact path is untouched), and a plain reader decodes
  identically with far fewer Reads (63,672 → a handful for a 63,684-byte
  stream; that subtest fails on the previous code). Benchmarks: plain
  file 7.2 → 84 MB/s, now indistinguishable from the bufio-wrapped case.

Signed-off-by: apostasie <spam_blackhole@farcloser.world>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@apostasie
apostasie merged commit 7184e23 into main Aug 16, 2026
9 checks passed
@apostasie
apostasie deleted the work branch August 16, 2026 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant