Get the latest tech news

Size Optimization Tricks (2022)


June 10th, 2022 @ justine's web page This blog post will cover some of the tricks I've used in the past to make c / c++ / python binaries smaller using x86 assembly. Much of it will revolve around the Cosmopolitan codebase, since I recently received feedback from the ELKS project that they love the code and want to hear more about how the tricks cosmo uses can potentially improve projects as intriguing as a i8086 Linux port.

Altavista ran an entire search engine on a single computer, and now you're telling me we need to plug our Full Story Elecron IDEs into a Kubernetes cluster to compile a C++ app that does math. If you want a 4kb hello world binary that only runs on Linux, and leaves out that hefty 12kb of bloat that's normally included to support Windows, MacOS, FreeBSD, NetBSD, OpenBSD, and booting from BIOS on bare metal. UNIX SYSCALL Magnums (x86-64) Function Linux FreeBSD OpenBSD NetBSD exit 60 1 1 1 fork 57 2 2 2 read 0 3 3 3 write 1 4 4 4 open 2 5 5 5 close 3 6 6 6 stat 4 n/a 38 439 fstat 5 551 53 440 poll 7 209 252 209 You'll notice there's a subset of numbers on which all systems agree, particularly among the BSDs.

Get the Android app

Or read this on Hacker News