Skip to content

Work - #1

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

Work#1
apostasie merged 8 commits into
mainfrom
work

Conversation

@apostasie

Copy link
Copy Markdown

No description provided.

Signed-off-by: apostasie <spam_blackhole@farcloser.world>
Signed-off-by: apostasie <spam_blackhole@farcloser.world>
  Since 7a6b5a0 widened the XOF buffer from one block to MaxSIMD blocks,
  Read has assumed or.buf holds the 1024-byte-aligned window of the
  stream containing or.off, indexing it with off%1024. Seek, however,
  still filled the buffer starting at the 64-byte-aligned block counter
  (off/64), so any seek to an offset with off%1024 >= 64 caused
  subsequent Reads to return bytes from the wrong stream position (up to
  960 bytes ahead) until the stale buffer drained. Existing tests only
  compared output at offsets below 64, where the two alignments
  coincide.

  Fill the buffer from the buffer-aligned counter instead, and add a
  regression test comparing seeks against a block-generated golden
  stream at unaligned offsets.

Signed-off-by: apostasie <spam_blackhole@farcloser.world>
  - reject offset+length overflow in ExtractSlice, DecodeSlice, and
    VerifyChunk; DecodeSlice previously reported success on overflowing
    bounds while verifying nothing
  - verify (rather than reject) the empty encoding in VerifyChunk, which
    computed a tree of -1 parent nodes for zero-length data; also verify
    the root of empty encodings in DecodeSlice instead of trivially
    succeeding
  - return errors from OutputReader.Seek when the target position would
    wrap past the end of the stream, instead of silently seeking to a
    wrapped offset
  - panic with clear messages in New for negative sizes and keys that are
    not 32 bytes; over-length keys were previously silently truncated
  - correct compressGroup's merge stack size (54-MaxSIMD read as 38; the
    intended bound is 64-10-4 = 50 levels)
  - make TestXOF's seek assertions compare real data (they previously
    read past the end of the reference buffer, comparing zero bytes) and
    add unaligned end-of-stream coverage with counters beyond 2^32

Signed-off-by: apostasie <spam_blackhole@farcloser.world>
  - add guts.CompressBlocksN, which computes only as many XOF blocks as
    requested on platforms without SIMD; small XOF reads previously cost
    16 compressions regardless of size
  - rework OutputReader to track its buffer as an absolute stream range
    and fill it lazily; Seek no longer compresses eagerly, and repeated
    reads within the cached range avoid recomputation
  - parallelize XOF output only when each goroutine gets at least 16 KiB
    of work, and distribute remainder buffers evenly instead of spawning
    a second round of goroutines
  - compress eigentrees smaller than 4 chunks inline in Write instead of
    spawning a goroutine per tree
  - copy sub-16-chunk eigentree tails into a stack buffer instead of
    growing the input slice on the heap (~48 KiB of garbage per large
    Write), and drop bytes.Buffer from the hot paths
  - reuse a single parent-CV buffer in bao.Encode, halving WriteAt calls
    and eliminating two heap allocations per parent node (~2050 allocs
    per MiB at group 0)
  - document that bao decoding benefits from buffered readers

  Benchmarks (Apple M5 Pro, generic path): streaming Write 1116→1194 MB/s
  and 1116→18 B/op; XOF 64 KiB 1743→1782 MB/s with 58→9 allocs;
  Sum256 1 MiB 48.5→14.2 KB/op; bao EncodeBuf 1 MiB 2050→5 allocs.

Signed-off-by: apostasie <spam_blackhole@farcloser.world>
Signed-off-by: apostasie <spam_blackhole@farcloser.world>
  - pin avo as a nested, GOSUMDB-verified module (avo/go.mod); fix the
    stale go:generate directive and verify regeneration reproduces the
    committed assembly byte-for-byte, enforced by a new lint-generated
    recipe (just gen regenerates)
  - add .golangci.yml tuned for a crypto library and fix every finding:
    un-shadow the copy builtin in ExtractSlice, correct two stale doc
    comments, rewrite if-else chains, drop redundant slicing, use
    errors.Is/strconv in tests; constrain guts/cpu*.go to amd64 so the
    cpuid dependency and SIMD flags vanish from other architectures
  - fill in the empty test recipe: simd capability report, unit, race,
    and a GOARCH=386 leg that runs natively on the amd64 CI runners —
    which also exercise the AVX2/AVX-512 kernels this laptop cannot
  - drop dead godoc/goreportcard badges from the README

Signed-off-by: apostasie <spam_blackhole@farcloser.world>
Signed-off-by: apostasie <spam_blackhole@farcloser.world>
@apostasie
apostasie merged commit 464007c into main Aug 3, 2026
8 checks passed
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