Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: optimize for size? #166

Open
domenpk opened this issue Feb 6, 2019 · 1 comment
Open

RFC: optimize for size? #166

domenpk opened this issue Feb 6, 2019 · 1 comment

Comments

@domenpk
Copy link
Contributor

domenpk commented Feb 6, 2019

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.

@bahrozjaved
Copy link

you think that in my repo there is a memory mamnagement issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants