SeattleMeshnet / meshbox

The Hyperboria peering device
https://github.com/hyperboria/cjdns
GNU General Public License v3.0
141 stars 25 forks source link

Strip down bytesize of cjdroute #14

Closed ghost closed 9 years ago

ghost commented 10 years ago

Current, for openwrt-x86_64: 617kb -rwxr-xr-x 1 root root 617336 Jul 30 09:16 /usr/sbin/cjdroute

cjd suggested a few things:

<larsg> cjd: do you have anymore suggestions for reducing cjdroute size, apart from sstrip?
<cjd> stop log_debug
<cjd> not very helpful though
<cjd> oh
<cjd> -Os
<cjd> but beware the consequences, it might cause surprisecrash
<larsg> is that an optimization step that doesn't go for performance, but for binary size?
<cjd> yup
<larsg> cool, will try both
<larsg> maybe we can get at least below 600 kb on openwrt
<larsg> did you get your windows stuff merged in libuv?
<cjd> mmm no
<larsg> maybe we remove some of libuv
<cjd> yup, strip unused functions
<larsg> right sstrip probably already takes care of that
<cjd> mmm actually I think the linker is needed for that
<cjd> but you can check
<larsg> ok that's a third thing that, good
kpcyrd commented 10 years ago

how's the impact of the changes in cjdelisle/cjdns/pull/616 and cjdelisle/cjdns/pull/617?

ghost commented 10 years ago

We only copy the compiled executables, plus contrib/lua.

ghost commented 10 years ago

We could be more selective with the Lua files, on that note.

ghost commented 10 years ago

Just noticed OpenWrt already compiles cjdns with -Os

ghost commented 9 years ago

There are a couple of instances where cjdns' make.js overrides -O set via CFLAGS/LDFLAGS.

wfleurant commented 9 years ago

If the PPP support is removed from the build then a 4MB friendly firmware including cjdns and luci-app-cjdns can be built.

3.3M openwrt-ar71xx-generic-whr-hp-gn-squashfs-factory.bin
3.3M openwrt-ar71xx-generic-whr-hp-gn-squashfs-sysupgrade.bin
3.3M openwrt-ar71xx-generic-whr-hp-gn-squashfs-tftp.bin
CHAOS CALMER (Bleeding Edge, r42689)
root@OpenWrt:~# opkg list | grep cjd
cjdns - 0.10-1
luci-app-cjdns - 1.3-1
root@OpenWrt:~# ip6tables -t nat -S
-P PREROUTING ACCEPT
-P INPUT ACCEPT
-P OUTPUT ACCEPT
-P POSTROUTING ACCEPT

Considering the above, the documentation should highlight the support for routers with 4mb flash depend on a bundled firmware build which (in this case) does not include PPP support, kernel symbols, debugfs.. Perhaps meshbox hardware could grab future firmware-sysupgrade images from the buildbot server. Best solution -- getting size of a mips32 cjdroute binary low enough to reside on the /overlay JFFS2 for all firmware.. Giving the user the choice between upgrading the cjdns package, and upgrading their routers firmware.

ghost commented 9 years ago
$ rm -rf build_linux/ && ./do && la -la cjdroute && strip --strip-all cjdroute && ls -la cjdroute
[...]
-rwxrwxr-x 1 lars lars 1612512 Nov 28 07:16 cjdroute
-rwxrwxr-x 1 lars lars 693464 Nov 28 07:16 cjdroute

This, combined with a bit of make.js hackery (https://github.com/lgierth/cjdns/commit/19d21f74b0a9b0dde89b2d22eebf5f01f634c2d7) brings me down to 693464 bytes... not as much as I hoped.

ghost commented 9 years ago

And with the OpenWrt buildroot (i.e. with uClibc) the make.js hackery gets us down from 707496 to 682920.

24.5 KB, at least.

ghost commented 9 years ago
<cjd> -rwxrwxr-x 1 user user 488816 Jan 25 02:46 ./cjdroute
ghost commented 9 years ago

We're at 460 to 520 KB now, depending on the target -- that's 200 KB less. I've also worked on the Lua files a bit, we now have our own copy of only the files we need.

Best solution -- getting size of a mips32 cjdroute binary low enough to reside on the /overlay JFFS2 for all firmware

@wfleurant how close are we to fitting into /overlay? We can certainly remove PPP support from the buildbot's images.

ghost commented 9 years ago

We fit now.