Binary size on MCU #2699
Replies: 6 comments 17 replies
-
My ui code:
Hello World code:
|
Beta Was this translation helpful? Give feedback.
-
You could try to gradually re-add pieces to see what's contributing how much. I suspect that the glyph images resulting from different text sizes are a big factor. It would also be interesting to see how much the Button contributes, and how it differs between fluent and material. It might be worth omitting it in favor of a simpler self-made one, without the bells and whistles of dark/light mode and icons. @xgroleau might also have some experience with this. Another thing to try is to use opt-level="s" (worked better for me than z, but YMMV) |
Beta Was this translation helpful? Give feedback.
-
I've updated the original post with data from following tests: Using only default font size saves 54 KiB a lot (I've expected more tbh) I'll try setting cargo in a way that ui generated form slint would be compiled with optimized for size while rest of my app is optimized for performance. I'll let You now how it goes. |
Beta Was this translation helpful? Give feedback.
-
I've played around with objdump a little:
4.REL1 fonts take ~7K
In practice GUI app will often need more than one font size but 60K is not end of the world. |
Beta Was this translation helpful? Give feedback.
-
I do agree that slint does use quite a lot of flash, which is also a problem for us, the UI takes more than 60% of our flash which leaves not a lot for application code and bootloader.
Your code seem to already respect that so I'm not sure how you can actually optimize more on your end other than reducing the number of components. For the different font sizes, it could be possible to make slint resize the font at runtime for a bit of runtime overhead, but that would require modification of the slint library itself. It's not an ideal solution but you could use an external NOR flash and XIP if your MCU supports it instead of using an MCU with bigger flash. I'm interested on what you will find on the usage and see if it's possible to optimize the flash usage of the library |
Beta Was this translation helpful? Give feedback.
-
From a glance at the output it seems that
inside the I suspect that There are surely things that can be done to reduce the size of generated code. Maybe along the lines of commit 52aee8d. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm writing a MCU application in rust. I've used slint to make a simple UI for 320x240 screen. One big problem I've noticed is that slint is using a lot of flash.
DEV: Dependency crates are optimized for size while my crate is not optimized:
REL1: Optimized for speed:
REL2: Optimized for size:
REL3: REL2 with opt-level = "s"
I've included comparison to embedded graphics to give idea of how much flash is taken to get slint running.
It comes out to ~155KiB with REL1 settings. That's quite a bit but acceptable.
The most interesting numbers are 3.REL1 and 4.REL1 and those are bad.
The UI I've made is consists of only one screen without any images. At this rate It's unlikely that the project will fit on 512K flash that I use.
What is causing such high resource usage? / Any Tips on how can I investigate that?
Are there any settings that I can change to make the binary smaller?
Are there any plans to make slint less resource hungry? If so, how much of improvement can be expected?
Is there any low hanging fruit?
Beta Was this translation helpful? Give feedback.
All reactions