fhunleth
Co-author of Nerves
I realize that most people aren’t overly concerned with OTP release sizes. I hadn’t been, but an issue came up where over-the-air updates over an LTE connection actually starts costing money. The OTP release on my device occupies about 55% of the space, not counting beam.smp. I was looking at the application sizes in a release. Here’s a sampling of the top sizes (in KB) I’m seeing:
$ du -ks * | sort -rn
4652 elixir-1.7.4
4012 stdlib-3.6
1792 kernel-6.1
1736 compiler-7.2.7
1136 ssl-9.0.3
1028 asn1-5.0.7
912 public_key-1.6.3
900 mix-1.7.4
880 ssh-4.7.1
780 distillery-2.0.10
372 sasl-3.2.1
312 iex-1.7.4
308 runtime_tools-1.13.1
204 crypto-4.3.3
200 socket-0.3.13
184 x509-0.5.0-dev
148 nerves_network-0.3.7
144 logger-1.7.4
136 nerves_runtime-0.8.0
128 system_registry-0.8.0
I’ve configured Distillery to strip debug out of the .beam files. That helped, but not as much as I hoped. As you can see, Elixir and stdlib are still over 4 MB and there are quite a few decent size ones after that. If those could be reduced, that would be a decent win for me. Has anyone tried doing this? Any ideas?
Thanks!
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
I think I’ve found a small improvement I could contribute to <%= web_namespace %>.CoreComponents (installer/templates/phx_web/compo...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
ICal is a library for interacting with iCalendar data. It parses iCalendars into typed Elixir structs via ICal.from_ics, and can prepare ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #elixirconf-us
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
michalmuskala
I’m pretty sure the majority of the size of Elixir will be the Unicode modules. The new compiler in OTP 22 might be actually better at compiling things like that, which might reduce the size somewhat. The issue is even bigger since now the Erlang’s stdlib contains another copy of unicode too.
One more thing you could try is compiling everything without line info (the option to compiler is
no_line_info). This might create more opportunities for compiler passes that merge similar code together if they only differ by a line number, but that’s kind of a long shot.LostKobrakai
I’m wondering if incremental updates would help you as well. I often update my releases not by uploading the whole thing, but by using rsync to just upload what’s changed.
michalmuskala
Actually, the pass that removes line information if passed the
no_line_infoflag runs after the pass that tries to share identical code between branches, so it wouldn’t change anything unfortunately.josevalim
Yes. It is worth noting that Elixir v1.8 will be slightly smaller on this aspect though because we no longer ship with the normalization behaviour (the Erlang implementation was smaller and faster).
However, if you look at each individual .beam file, it is most likely that the sizes are coming from the Dbgi (ast) and Docs chunks, and they are both optional, so that’s what I would consider removing first. I wouldn’t be surprised if it reduces the size to half.
michalmuskala
I believe stripping the release in distillery should be removing data from both the dbgi and docs chunks already, shouldn’t it?
josevalim
The
ebinof my local Elixir checkout is 4.6MB so I am assuming the ones above have not been pruned.fhunleth
You’re right. Debug info isn’t being stripped from the
.beamfiles in the firmware. Let me figure out why that isn’t happening and post an update on sizes.fhunleth
Definitely. I’m very interested incremental updates. It’s a little more work for me to add that to Nerves, though, so my initial goal is to cleanup my project’s firmware releases and see where things stand. (Apologies to people making web kiosks with Nerves - I’m aware that incremental updates are the only way to truly reduce your firmware sizes.)
fhunleth
Here’s the update:
distilleryaruntime: falsedependency. This also removes the need formixto be in the release. This dropped the size by 4.5%, but it felt good to not include the build tools. I’ll obviously need to reconsider if we start using the config providers.beamfiles trimmed the firmware by 35%! Everything (Linux kernel,beam.smp, drivers, wifi firmware, bootloaders, and the OTP release) are now in a 15.2 MB package.nerves_system_br.I’m not out of the woods with size, but I’m going to savor this improvement over the Thanksgiving holiday here. I also want to see if I can live with the stripped beams.
Here are some stats:
After stripping the beams:
Post strip, here’s example contents of a .beam file (this one is the current winner on size in the Elixir app)
I would assume that means that line number info is still present, but it looks too small to worry about.
michalmuskala
My comment about line info wasn’t about the fact that it in itself is large. It’s more that in modules like
BaseandString.Unicodethere’s a large degree of code duplication that can be merged between different branches, etc. Unfortunately, in many cases this can’t be done, because there’s line info for building stacktraces that differs between those branches. Removing line info could help reduce that duplication further. Unfortunately, the compiler pass that applies theno_line_infooption runs after the optimisation pass that could potentially remove the duplication.