RFC: optimize for size?
I was looking at led-roulette disassembly and something looked a bit off. A loop going through 8 LEDs was unrolled.
In my experience, it's normally size that developers care about and compare, so we might not want to look bad in that respect.
Changing opt-level to s or z, reduces the sizes of binaries by about 1kB:
As is:
4762 1816 4 6582 19b6 hello-world
4750 1152 4 5906 1712 registers
4510 1152 4 5666 1622 leds-again
4774 1152 4 5930 172a clocks-and-timers
4682 1152 4 5838 16ce usart
5910 1472 4 7386 1cda i2c
6704 1312 4 8020 1f54 led-compass
30766 10032 4 40802 9f62 punch-o-meter
opt-level = "s":
3682 1816 4 5502 157e hello-world
3900 1152 4 5056 13c0 registers
3686 1152 4 4842 12ea leds-again
3904 1152 4 5060 13c4 clocks-and-timers
3866 1152 4 5022 139e usart
4960 1476 4 6440 1928 i2c
5724 1312 4 7040 1b80 led-compass
28230 10032 4 38266 957a punch-o-meter
opt-level = "z":
3642 1816 4 5462 1556 hello-world
3858 1152 4 5014 1396 registers
3642 1152 4 4798 12be leds-again
3902 1248 4 5154 1422 clocks-and-timers
3822 1152 4 4978 1372 usart
4910 1476 4 6390 18f6 i2c
5604 1312 4 6920 1b08 led-compass
28134 10032 4 38170 951a punch-o-meter
Output created by:
for i in [0-9]*; do cd $i; bin=$(grep name Cargo.toml | cut -f2 -d'"'); cargo size --target $target --bin $bin --release | tail -1 >> ../size_z.txt ;cd ..; done
I'd create a pull request, but thought I'd first ask what are your views on this.
you think that in my repo there is a memory mamnagement issues