From 302897c5e8d61db9107505ba929f9abfc197896d Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Wed, 29 Jul 2026 00:49:47 +0200 Subject: perf: DEFLATE (puff) + -no-pie -> OF binary 879 KB -> 662 KB (-25%) Two size wins: - Replace the home-grown LZSS (2.0x) with DEFLATE: mktext gzips the text and strips the gzip container to a raw DEFLATE stream; clectio decompresses it with puff, Mark Adler's public-domain reference inflate (~200 lines, verified byte-identical to gunzip on the OF/EF text, repetitive, random and empty inputs). Text blob 671 KB -> 492 KB (OF), 164 KB -> 132 KB (EF), 2.7x. - Build with -no-pie: clectio is a local CLI reading static embedded data with no attack surface, so it needs no PIE/ASLR. The linker then bakes the string- table pointers in at link time instead of emitting ~57 KB of runtime relocations. Net: OF 879 -> 662 KB, EF 266 -> 214 KB. Verified byte-identical to lectio. The default build still needs only a compiler + libc; a CORPUS= rebuild now also needs gzip. lz.h removed. Claude-Session: https://claude.ai/code/session_01S1CD1u3tgSS4xNu6WHfp5a --- puff.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 puff.h (limited to 'puff.h') diff --git a/puff.h b/puff.h new file mode 100644 index 0000000..34e7649 --- /dev/null +++ b/puff.h @@ -0,0 +1,15 @@ +/* puff.h -- interface to puff(), a simple DEFLATE decompressor. + * puff.c is Mark Adler's public-domain reference inflate (from zlib/contrib). + * clectio uses it to unpack its compiled scripture text, which the build packs + * with gzip (a raw DEFLATE stream; the gzip header/trailer are stripped by + * mktext, which stores [uint32 raw length][raw DEFLATE]). + */ +#ifndef PUFF_H +#define PUFF_H + +int puff(unsigned char *dest, /* pointer to destination pointer */ + unsigned long *destlen, /* amount of output space / used */ + const unsigned char *source, /* pointer to source data pointer */ + unsigned long *sourcelen); /* amount of input available / used */ + +#endif -- cgit v1.3