Hi!

https://fedoraproject.org/wiki/Changes/ZRAMforARMimages is a change to
automatically create a zram device on memory-constrained systems. It is
implemented using 'zram' package, which uses a service unit and two
bash scripts to implement the starting and stopping of the zram device.

I wanted to explore an alternative approach, using a systemd generator [1],
to create (or not) the unit to create the zram device. The advantages are:
- lower footprint (a custom binary instead of a shell script using
  grep, awk, and whatnot)
- completely invisible if the memory limits are not met, no "skipped" units
- minimalistic: the unit just creates the device, but tells
  systemd-modules-load.service to actually load the module, 
  and creates a .swap unit for the device, so it will be managed by systemd
  in the usual fashion.

Systemd generators are often written in C, to keep them mean and lean, but
C is not an attractive option for many people. We have wanted to explore
the approach of writing generators in Rust. zram-generator doubles as a
proof-of-concept and example of a simple-yet-not-trivial systemd generator
in Rust.

Without further ado: upstream project [2], fedora package review [3].
Many thanks to Igor Gnatenko and Martin Sehnoutka for reviews of the code.

It works like this:
1. /usr/lib/systemd/zram-generator runs, checks if we have less memory than the 
limit
2. /run/modules-load.d/zram.conf is created to have "zram" module loaded
3. /run/systemd/generator/swap-create@zram0.service is created, it'll
   initialize /dev/zram0
4. /run/systemd/generator/dev-zram0.swap is created, and added to swap.target
5. swap.target is pulled in by systemd, the config from items 2, 3, 4 is
   executed.

[1] https://www.freedesktop.org/software/systemd/man/systemd.generator.html
[2] https://github.com/systemd/zram-generator
[3] https://bugzilla.redhat.com/show_bug.cgi?id=1622127

Comments, ideas, reviews of the package, etc, are very much welcome.

I think this might be used to replace the 'zram' package, but it's too early
to say.

Zbyszek
_______________________________________________
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/PCP7YAF7LBF5MLI36XWYNISQCYIDRNHS/

Reply via email to