From owner-cvs-all Thu Nov 14 14:57:52 2002 Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5308A37B404; Thu, 14 Nov 2002 14:57:49 -0800 (PST) Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1B0C843E6E; Thu, 14 Nov 2002 14:57:49 -0800 (PST) (envelope-from dillon@apollo.backplane.com) Received: from apollo.backplane.com (localhost [127.0.0.1]) by apollo.backplane.com (8.12.5/8.12.5) with ESMTP id gAEMvgFC071779; Thu, 14 Nov 2002 14:57:42 -0800 (PST) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.12.5/8.12.5/Submit) id gAEMvdxX071776; Thu, 14 Nov 2002 14:57:39 -0800 (PST) (envelope-from dillon) Date: Thu, 14 Nov 2002 14:57:39 -0800 (PST) From: Matthew Dillon Message-Id: <200211142257.gAEMvdxX071776@apollo.backplane.com> To: "M. Warner Losh" Cc: sobomax@FreeBSD.ORG, silby@silby.com, njl@FreeBSD.ORG, cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG Subject: Re: cvs commit: src/bin/sleep sleep.c References: <200211132012.gADKCQxr062768@repoman.freebsd.org> <20021113204503.GI9006@vega.vega.com> <20021113.215346.90827277.imp@bsdimp.com> Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I think the real issue is the bloat in libc. printf() eats 20K, basic stdio eats 5K. You get 15K of bloat just with a blank main(), a good chunk of that being malloc() (reasonable in larger programs, ridiculous in tiny programs where you don't care about malloc() efficiency). (static link output) -rwxr-xr-x 1 dillon dillon 52873 Nov 14 14:36 x printf("X\n"); -rwxr-xr-x 1 dillon dillon 21493 Nov 14 14:36 x puts("X"); -rwxr-xr-x 1 dillon dillon 21493 Nov 14 14:36 x puts("X"); -rwxr-xr-x 1 dillon dillon 15109 Nov 14 14:38 x main() -rwxr-xr-x 1 dillon dillon 959 Nov 14 14:55 x _start() / no libc -rwxr-xr-x 1 dillon dillon 959 Nov 14 14:55 x _start() + phk malloc -rwxr-xr-x 1 dillon dillon 13409 Nov 14 14:56 x My zalloc implementation, which I could turn into a poor-man's malloc in 10 seconds (and is used in libstand) eats 1.7K. My *printf() core (pfmt) from DICE, which handles 95% of the capabilities of *printf, is 1.9K. I could adapt the stdio library from DICE to fit in probably less then 2K, assuming one actually referenced every single function. Why not create a mini-libc? No language-aware character conversions, no efficient string or memory functions, no floating point. Just a basic implementation of the core functionality required for stdio, malloc, *printf(), string functions, and system calls (which will simply be borrowed from libc), sufficient for simple binaries. It could be made compatible with our standard includes (structural bloat != code bloat, so who cares). I could whip this up in a day or two. I'm not kidding. I already have most of the necessary pieces from my embedded libraries and DICE libraries. -Matt Matthew Dillon : :In message: <20021113204503.GI9006@vega.vega.com> : Maxim Sobolev writes: :: On Wed, Nov 13, 2002 at 03:32:13PM -0500, Mike Silbersack wrote: :: > :: > On Wed, 13 Nov 2002, Nate Lawson wrote: :: > :: > > njl 2002/11/13 12:12:26 PST :: > > :: > > Modified files: :: > > bin/sleep sleep.c :: > > Log: :: > > Remove getopt and strtol dependencies, reducing size of static exe. :: > > Preserve older desired behavior, accept [+-]*[0-9]*\.[0-9]* :: > > Remove a few unnecessary casts. :: > :: > Please don't commit crap like this. While having smaller binaries might :: > be nice, being entered into an obfuscated C contest is not one of the :: > goals of FreeBSD. :: :: I fully agree - HDD space is pretty cheap today, while embedded folks :: should use other means to reduce footprint (e.g crunchgen). Actually :: in the case of crunchgen this commit worsens situation, as the code :: is no longer shared. : :It also makes the dynamic binary larger for the folks that have / and :/usr on the same partition and dynamically link /sbin and /bin. Much :more bang for the buck that these silly micro-optimizations. So this :is a negative thing as far as I'm concerned. :-( : :Warner : To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message