Skip to content

Cleans up several oversized functions across std::hash (SHA-256, Streebog, BLAKE3) and std::compression (ZIP, Deflate): - #3487

Merged
lerno merged 6 commits into
c3lang:masterfrom
ManuLinares:bloat
Aug 30, 2026
Merged

Cleans up several oversized functions across std::hash (SHA-256, Streebog, BLAKE3) and std::compression (ZIP, Deflate):#3487
lerno merged 6 commits into
c3lang:masterfrom
ManuLinares:bloat

Conversation

@ManuLinares

Copy link
Copy Markdown
Member
  • Replaces repetitive macro expansions in Streebog and BLAKE3 with shared @noinline functions and pointer passing.
  • Unifies aligned/unaligned SHA-256 transform paths to avoid duplicate 64-round bodies.
  • Breaks up monolithic ZIP (open, close, open_reader) and Deflate (emit_block, pkg_merge) functions into private helpers.

Reduces frontend IR instruction counts without affecting runtime performance or behavior.

instruction_reduction_results

Merge `_transform` and `_transform_unaligned` so the 64-round body is
only emitted once, handling alignment directly during the initial
16-word buffer load.
Convert `@g_n` and `@_streebog_stage2` from macros to `@noinline`
functions to prevent the transform loop from expanding multiple times
in `update` and `streebog_final_private`.
Pass pointers rather than slices into `compress_pre` to avoid bounds
checking on round indexing, and convert `compress_in_place` and
`compress_xof` into functions instead of inline macros.
Split out central directory parsing, EOCD discovery/writing, and
AE-X setup from `open`, `close`, and `open_reader` into private
helpers to make the main control flow easier to follow.
Extract token encoding and RLE compression helpers from `emit_block`,
and use a temporary slice rather than `List` in `pkg_merge`.
@ManuLinares

ManuLinares commented Aug 30, 2026

Copy link
Copy Markdown
Member Author

Hyperfine shows 5.9% faster builld times for the stdlib

hyperfine \
  --warmup 5 \
  --runs 100 \
  --prepare 'git checkout bloat >/dev/null 2>&1' \
  './build/c3c compile hello.c3 -O1 --strip-unused=no -g0' \
  --prepare 'git checkout master_upstream >/dev/null 2>&1' \
  './build/c3c compile hello.c3 -O1 --strip-unused=no -g0'

Comment thread lib/std/compression/deflate.c3 Outdated
@lerno
lerno merged commit 502f3c9 into c3lang:master Aug 30, 2026
18 checks passed
@lerno

lerno commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

I removed some @noinline, because I feel it's better to allow the compiler to have control over that. Also, I've tried to move the local part to the end of the files for ease of reading.

@ManuLinares

Copy link
Copy Markdown
Member Author

I removed some @noinline, because I feel it's better to allow the compiler to have control over that.

👍️

Synthetic benchs consistently regressed O2/O3 by about 3–4%, while O1 stayed flat.
But I think in a real use of blake3, this result is meaningless.

@ManuLinares
ManuLinares deleted the bloat branch August 30, 2026 17:47
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.

3 participants