systemd / zram-generator

Systemd unit generator for zram devices
MIT License
575 stars 48 forks source link

Description of host-memory-limit #181

Closed ericjs closed 1 year ago

ericjs commented 1 year ago

I'm having a hard time understanding the comment describing host-memory-limit in zram-generator.conf.example. What effect does this setting have? What should it be set to?

Is it meant to be set to the size of the physical memory of your machine? Or the amount of memory you want to ensure you have left after zram takes some?

nabijaczleweli commented 1 year ago

FTR, the sample says:

[zram0]
# This section describes the settings for /dev/zram0.
#
# The maximum amount of memory (in MiB). If the machine has more RAM
# than this, zram device will not be created.
#
# "host-memory-limit = none" may be used to disable this limit. This
# is also the default.
host-memory-limit = 9048
[zram1]
# This section describes the settings for /dev/zram1.
#
# host-memory-limit is not specified, so this device will always be created.

Which, idk.

"What effect does this setting have?" If the machine has more RAM than this, the zram device is not created.

"What should it be set to?" You probably don't care if you're writing a single config for a single machine, since you know how much memory your machine has.

"Is it meant to be set to the size of the physical memory of your machine?" No, and I think this is unfounded in the above.

"Or the amount of memory you want to ensure you have left after zram takes some?" Likewise.

The manual says:

host-memory-limit=

Sets the upper limit on the total usable RAM (as defined by MemTotal in /proc/meminfo, confer proc(5)) above which the device will not be created.

This takes a nonnegative number, representing that limit in megabytes, or the literal string none, which can be used to override a limit set earlier.

Defaults to none.

Which is just about the same.

ericjs commented 1 year ago

@nabijaczleweli , in particular I'm confused by that if the machine has more RAM than this, the zram device is not created. Why is this behavior desirable? Perhaps if I knew that, I'd understand the purpose of this setting. What is a scenario where one would want to set it?