Re: Proposal: remove /usr/bin/minigzip

From: Xin Li <delphij_at_delphij.net>
Date: Fri, 29 Jul 2022 07:52:36 UTC

On 7/28/22 23:24, Eugene Grosbein wrote:
> 29.07.2022 13:12, Xin Li пишет:
>> Hi,
>>
>> I'd like to remove /usr/bin/minigzip , a patch is available at:
>>
>>      https://reviews.freebsd.org/D35979
>>
>> The minigzip is originally an example application shipped with zlib to demonstrate how to use it to implement basic functionality of gzip.  It was connected to the base system in 1997, mainly because there wasn't a GPL-free implementation of gzip(1):
>>
>>      https://cgit.freebsd.org/src/commit/usr.bin/minigzip?id=85e55f7ab8473307fb16c5bce8c2e933a317215b
>>
>> Now we already have a GPL-free gzip(1) implementation in base system for quite a while, so it seems that there isn't much value of keeping minigzip around.  A quick grep suggests that it's not being used by the base system anywhere, nor in the ports tree.
>>
>> Any objections?
> 
> Have you considered embedded applications (crunchgen etc.)?

Yes, but I don't think it's being used in real life anywhere, base 
system crunchgen examples, including rescue and tools/bsdbox, are all 
using the real gzip.

> In 13.1/amd64, /usr/bin/minigzip binary is about 11KB and links with libc and libz only.
> 
> OTOH, /usr/bin/gzip is about six times larger (64KB) and additionally needs libbz2, liblzma, libmd and libthr.

It's a little bit unfair to compare the sizes of the executables 
directly :-)  After all, the C library accounted for 94.4% and 75.4% of 
space for minigzip and gzip respectively:

$ F=/usr/bin/minigzip; du -Akc $(echo ${F} $(ldd -f '%p\n' ${F} | grep 
^/ | sort))
12	/usr/bin/minigzip
1939	/lib/libc.so.7
104	/lib/libz.so.6
2054	total

$ F=/usr/bin/gzip; du -Akc $(echo ${F} $(ldd -f '%p\n' ${F} | grep ^/ | 
sort))
63	/usr/bin/gzip
1939	/lib/libc.so.7
107	/lib/libmd.so.6
122	/lib/libthr.so.3
104	/lib/libz.so.6
77	/usr/lib/libbz2.so.4
163	/usr/lib/liblzma.so.5
2573	total

So yes, gzip is bigger, but arguably it's just about 0.5MiB, or 25% 
larger, and among that 2573KB, 2510KB or 97.6% was shared library.

But for applications that really want to have smaller footprint, bzip2 
might be a better alternative -- the binary is bigger than minigzip, but 
library was smaller than zlib so the total size is actually a little bit 
smaller:

$ F=/usr/bin/bzip2; du -Akc $(echo ${F} $(ldd -f '%p\n' ${F} | grep ^/ | 
sort))
34	/usr/bin/bzip2
1939	/lib/libc.so.7
77	/usr/lib/libbz2.so.4
2050	total

(It's true that zlib is a much more popular library and is used in more 
scenarios, like ppp, etc., so in reality this might actually added 99kb 
(=34+77-12), I just wanted to say that there are other options, and if 
minigzip is not really being used, building it on every FreeBSD machines 
doesn't seem to be a good use of resources).

Cheers,