Yes imo better create the file in etc, but your guide already does this?
nano /etc/systemd/system/home-swap-swap0.swap
Yes imo better create the file in etc, but your guide already does this?
nano /etc/systemd/system/home-swap-swap0.swap
I’ve corrected it before your confirm, thx!
This seems to work well on my X 10 II.
root@Xperia10II-DualSIM:/home/defaultuser
> swapon --show
NAME TYPE SIZE USED PRIO
/dev/zram0 partition 4G 806.3M 5
/home/swap/swap0 file 1024M 0B -2
root@Xperia10II-DualSIM:/home/defaultuser
> free -h
total used free shared buff/cache available
Mem: 3.5G 1.9G 527.6M 17.2M 1.1G 1.9G
Swap: 5.0G 806.2M 4.2G
Screenshot, 3 browsers open, one of them playing a video:

I can switch between windows all I want, no crashes.
The clear change in all 3 graphs is when you activated the optimizations discussed here?
AFAICS swap here does not differentiate between physical swap & zram?
@mive I think you mentioned physical swap being really slow on an encrypted partition?
OTOH it’s good to have swap encrypted.
Do you have comparative numbers on responsiveness, or at least anecdotal experience?
How much is physical swap even used in this scenario?
@RootGPT could you please explain 1 more time how it works that ZRAM can be 100% the size of physical RAM? I mean it’s still inside physical RAM. Is that the size before compression? Is the compression that good?
BTW, can we agree that this works equally well on at least Xperia X10 II and X10 III, if not all Xperias with 4GB of RAM?
PS:
I’d also love to hear critical voices, who think all this is not a good idea.
In practice it works like this: ZRAM can be as large as physical RAM because that number is only the VIRTUAL size of the compressed data. What actually goes into real RAM is the data after compression, so it takes up less space. It’s just an indicative value, not a real one. In fact, ZRAM can theoretically even exceed physical RAM, but that’s not a good idea — I’ll explain why in a moment.
Compression is actually very effective, because many memory pages compress extremely well. So with 1 GB of real RAM you can store 2–3 GB of compressed data, depending on the content.
I’ve always said not to exceed physical RAM because ZRAM still lives in symbiosis inside RAM. If you make it too large, you risk taking RAM away from apps just to store unnecessary compressed data, and you also force the CPU to work harder to compress/decompress everything (nothing is free in this world). In the end, you may actually make performance worse instead of better.
Purists will forgive me, but with the right swappiness, ZRAM=RAM, and a good compression algorithm, you could say the device behaves as if it had gained a solid 50% of extra real RAM.
I’ve just tested the updated implementation with swap located @home on my main device. Together with the Android13 update by the 5.0.0.73, I’m now pretty sure the X10III has @least 3 to 4 more years to go!
I hope so! Thx for your feedback!