ecdye / zram-config

A complete zram-config utility for swap, directories, and logs to reduce SD, NAND and eMMC block wear.
MIT License
412 stars 53 forks source link

Any way to create multiple devices per core? #68

Closed derzahla closed 2 years ago

derzahla commented 3 years ago

First of all, thank you very much for zram-config. I have been using it with great results. The thing I am unclear on, is I thought it was best practice to split up your zram devices by number of CPU cores. Note: I am only using zram for swap, not to store any files. But even if I create 4 lines in my ztab like:

# swap  alg             mem_limit       disk_size       swap_priority   page-cluster    swappiness
swap    zstd            512             2048M           75              0               90
swap    zstd            512             2048M           75              0               90
swap    zstd            512             2048M           75              0               90
swap    zstd            512             2048M           75              0               90

I end up with a single zram device of 2GB:

zramctl
NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 zstd            2G   4K   70B    4K       4 [SWAP]

I am also curious about your disk_size parameter, as zram-config is the only implimentation I see it in. Most other zram management utilities(including systemd-swap) set the disk size to the exact same size as the physical RAM that is being dedicated to zram. Doesnt that mean that the system will never try to pack more into the zram drive? Or does a zram device only report the compressed size of the data inside of it? And if that's the case, why would you want to specify a larger zram disk size than it's physical memory backing? Thanks!

ecdye commented 3 years ago

First of all, thank you very much for zram-config. I have been using it with great results.

Thanks, I am glad you are enjoying it.

The thing I am unclear on, is I thought it was best practice to split up your zram devices by number of CPU cores.

I am not aware of anything that would make it more optimal to split up zram devices by the number of CPU cores, and as such it is probably unnecessary. Zram is fairly low impact on processing power anyway.

Note: I am only using zram for swap, not to store any files. But even if I create 4 lines in my ztab like:

# swap  alg             mem_limit       disk_size       swap_priority   page-cluster    swappiness
swap    zstd            512             2048M           75              0               90
swap    zstd            512             2048M           75              0               90
swap    zstd            512             2048M           75              0               90
swap    zstd            512             2048M           75              0               90

I end up with a single zram device of 2GB:

zramctl
NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 zstd            2G   4K   70B    4K       4 [SWAP]

Well, I am not sure what would cause this behavior, it should still create all of the devices you request, although I believe it is unnecessary to split up zram devices by core, if you provide me with the debug log found at /usr/local/share/zram-config/log/zram-config.log I will attempt to debug and figure out why it might not be working.

I am also curious about your disk_size parameter, as zram-config is the only implimentation I see it in. Most other zram management utilities(including systemd-swap) set the disk size to the exact same size as the physical RAM that is being dedicated to zram. Doesnt that mean that the system will never try to pack more into the zram drive? Or does a zram device only report the compressed size of the data inside of it? And if that's the case, why would you want to specify a larger zram disk size than it's physical memory backing? Thanks!

The disk size is a different parameter because it represents the size of the files as they appear on the disk uncompressed. This is different because the compressed size is the limiting factor in RAM usage. The disk size should always be larger than the memory limit because it will be the uncompressed size you believe the directory will reach at maximum whereas the memory limit will be the compressed size that you believe the directory will reach at a maximum. The memory limit will change slightly depending on the efficiency of the compression algorithm being used.

I apologize for the delayed response, I have been very busy lately. I hope that I have helped to clarify what the disk_size parameter is meant for, please let me know of any further questions you may have.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.