[PATCH] store --help messages in compressed form. saves 35k
Denis Vlasenko
vda at ilport.com.ua
Wed Apr 5 09:29:52 UTC 2006
> >> Why don't you lzma (or bzip2) them?
> >
> >Indeed. bunzip2 code is even smaller than gunzip.
> >(lzma is non-standard, may be unavailable on build box,
> >so I hesitate to use it).
> >
> Could we make this a CONFIG option? Something like
> choice
> prompt "compress usage messages"
> default CONFIG_USAGE_NOCOMPRESSION
> help
> text.
>
> config CONFIG_USAGE_NOCOMPRESSION
> bool "Do not compress"
> help
> Store usage strings in uncompressed format. This uses alot of
> space.
>
> config CONFIG_USAGE_COMPRESS_GZIP
> bool "gzip"
> depends on CONFIG_GUNZIP
> etc, etc.
> endchoice
Yes, it's a "complete solution ofr all imaginable cases",
but isn't that an overkill? There is a reasonable heuristic:
1) verbose --help is big - compress it if CONFIG_FEATURE_VERBOSE_USAGE,
else (non-verbose --help) do not compress it at all.
2) bunzip code is small (3k) - always use bzip for compression.
Let's see what will happen in the worst case.
busybox configured with CONFIG_FEATURE_VERBOSE_USAGE,
and with only one applet (cp). "make sizes" diff:
@@ -44,6 +44,7 @@
00000033 T concat_subpath_file
00000034 T bb_full_write
00000034 T __libc_csu_fini
+00000036 T bb_full_read
00000038 T bb_verror_msg
0000003e T bb_ask_confirmation
00000043 T bb_xasprintf
@@ -52,14 +53,18 @@
0000004c T bb_vperror_msg
0000004f T cp_mv_stat2
00000052 T xreadlink
-00000059 T bb_show_usage
00000060 T is_in_ino_dev_hashtable
0000006f T add_to_ino_dev_hashtable
00000076 T run_applet_by_name
+000000be t get_bits
000000c1 t bb_full_fd_action
000000c4 T busybox_main
+000000e7 t start_bunzip
00000103 T cp_main
-00000158 R usage_messages
+00000115 T bb_show_usage
+00000126 r gzipped_usage
+000001c0 T uncompressStream
00000357 T bb_getopt_ulflags
000004dc b ino_dev_hashtable
000005f2 T copy_file
+0000068f t get_next_block
# size busybox.org.s/busybox busybox.compressed_usage2.s/busybox
text data bss dec hex filename
9747 432 1284 11463 2cc7 busybox.org.s/busybox
12781 448 1284 14513 38b1 busybox.compressed_usage2.sbusybox
In this degenerate case we pay the price of only 3 additional kb of text.
> I suspect that certain setups don't have a decompressor built in
Makefile magic in the patch will ensure bunzip decompressor will be
compiled in.
> nor
> available, or already have unlzma built-in, so it would be nice to be
> able to cope with all these.
Developer may lack lzma on build box, but we can be reasonably sure [s]he
will have bzip2.
--
vda
More information about the busybox
mailing list