Hacker News new | ask | show | jobs
by osigurdson 7 days ago
I did an experiment to see how small and efficient I could make a desktop Linux app. One thing I learned is GPU adds a lot of memory overhead without much benefit for very basic apps.
2 comments

I did a similar attempt to produce small AppImages for GTK applications where static binaries are not an option. With a bit of recompiling dependencies with different flags and trimming i18n away, I went from 897MB to ~20MB.

https://simonshine.dk/articles/nix-appimage-when-musl-is-not...

I initially tried GTK but found it added a lot of overhead. In my experiment, I used Wayland directly and draw the pixels using the CPU. Another trick was to render fonts directly. Using these approaches, the binary is under 300MiB and the initial PSS is < 1MiB.

I was thinking of maybe turning it into a minimal UI framework. I noticed that Quickshell apps in Hyprland are comparatively very large so something lighter weight might be useful.

I did exactly compare GTK with direct drawing and found that direct drawing is only faster when you don’t need typical UI components.

When you only want to update the part of the screen that changes, you quickly start to build a library, and GTK is such a library.

Only put it on the GPU if you have thousands of nearly identical operations to do
Agree. I learned quite a few things in this exercise, actually. Another one is that conventional font rendering uses a lot of memory as well. Link below if anyone is interested:

https://github.com/osigurdson/mib