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 --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 2852836..e6d0556 100644 --- a/README.md +++ b/README.md @@ -41,8 +41,9 @@ chapter/verse numbering: make CORPUS=/path/to/mybible.tsv clectio compiles in only the ~12000 verses the lectionary actually cites, so the -binary stays around 1 MiB whatever the Bible. A verse the corpus lacks prints -blank; it never fails the day. +binary stays well under 1 MiB whatever the Bible. A verse the corpus lacks prints +blank; it never fails the day. (The default build needs only a compiler; a +`CORPUS=` rebuild also needs `gzip`, which `mktext` uses to pack the text.) ## Coverage @@ -53,11 +54,11 @@ guessed. To extend it, regenerate `gen/` with lectio's `clectio-gen`. clectio.c the program: date -> table lookup -> print config.def.h compile-time configuration - lz.h a tiny LZSS codec (keeps the compiled text small) - mktext.c build tool: resolve verse keys against a corpus, pack the text + puff.c/.h DEFLATE decompressor (Mark Adler's puff, public domain) + mktext.c build tool: resolve verse keys against a corpus, gzip-pack the text bin2h.c build tool: embed the packed text as C gen/ generated, corpus-independent data (calendar + citations) - text_of.lz the default Vulgate text, packed (one per form) + text_of.lz the default Vulgate text, DEFLATE-packed (one per form) ## Licence -- cgit v1.3