[OnePlus 7 Pro ROMs, Kernels, Recoveries, & Other D] Freak07:
widevine falling back to L3 with an unlocked bootloader is completely unrelated to the kernel. Only a locked bootloader sets it back to L1. Only Pixel devices can have an unlocked bootloader and L1.

Morning Guys :)

so one is sleeping and everbody lose their heads about ZRAM :D

Regarding the ZRAM needs to be enabled thing otherwise it causes reboots. I´m following [MENTION=5438598]RenderBroken[/MENTION] ´s work on OP6/T devices for quite a while now. We´re also sometimes in contact. I noticed he had issues (reboots) when disabling ZRAM after it got introduced by OP.

I read the same in the Skydragon Kernel thread for OP7. That´s why I assumed it causes reboots/issues. (like I said orignally) I never actually tried it myself, especially because I have no desire to disable ZRAM.

What this post will be about:

In this post I will try to explain why ZRAM doesn´t hurt anything at least (maybe even benefits us). I´ll present some new points of view, which counter the common argument "ZRAM needs cpu power, it hurts battery life and is simply unneeded".

It´s nice to see [MENTION=7671171]NateDev[/MENTION] actually looking around at XDA for information. However nearly every information about ZRAM on XDA is quite dated, that it´s not really applicable to our situation today.

The post mentioned is from 2012, which is 2 years before ZRAM finally made it to mainline kernel from the staging area. Since then ZRAM received numerous updates.

What changed from back then?

Devices have now far more RAM than previously. Even the RAM chips are improved compared to a few years ago.

The CPUs on our phones now are not only several times more powerful, but also several times more energy efficient. (especially with EAS)

This means ZRAM, and the resulting compression/decompression, is extremely inexpensive compared to 4 years ago, on phones but also laptops/desktop machines.

I already changed the compression algorithm from lz0 (higher compression ratio) to lz4 (faster compression/decompression speed) in my kernel here.

What´s the "swappiness" doing exactly?

That is a far more complicated thing to explain.

Simply speaking it controls the balance between swapping out runtime memory, as opposed to dropping pages from the system page cache. It can have a value from 0 to 100.

A lower value means that it will try not to swap out page cache but keep it in memory.

A high value means try to more aggressively swap out unused page memory. (swap in these cases is ZRAM)

Therefore a swappiness value of 100 doesn´t mean everything is going to ZRAM. That´s not how this works.

This screenshot is from my device. It´s up for nearly 12 hours now, ZRAM is still only used by 803 MB in comparison to the actual RAM, which is currently filled with approx. 5GB.

Why might using ZRAM actually be a good idea?

So what´s the downside of having a swappiness value of 100. The only downside is the system has to move unused pages to ZRAM more often (this involves compression, which takes time and needs a tiny bit of CPU power) compared to a lower swappiness value.

This is very inexpensive on modern devices. It´s also connected to EAS and the efficiency introduced by using EAS. The EAS machinery will automatically choose the proper CPU, place the task in the most efficient cpuset and get the compression/decompression done the most efficient way.

I´d say this is less expensive than powering your screen on and off a few times more during a day. (I have no hard proof for this)

But setting swappiness to a value of 100 will surely avoid is the following scenario (which is way more expensive than compression with ZRAM happening) . If the actual RAM ever gets completely full, it´s way more expensive for your phone to evict anonymous and cache pages from memory to get more free RAM again, than to simply compress unused pages to LZ4. (LZ4 compression is extremely! fast)

That may very rarely happen on a device with 12 GB RAM, but there may be usage scenarios where 6GB can get full quite quickly by extremely resource hungry apps, badly coded apps, some social media apps.

I don´t consider myself a pretty heaver user, but back to the screenshot I posted earlier, a OP7/Pro with only 6GB of RAM with ZRAM disabled, may have a full RAM by now facing exactly the scenario described above. And I didn´t play any resource intensive game nor do I use social media like facebook or instagram.

After all the way RAM works on Android is: Unused RAM is bad RAM. If an app is stored in RAM it´s less expensive to load it, than to load the resources again into RAM. That´s why RAM Boosters/Cleaners are one of the worst things you can do to your phone.

If we follow that train of thought, having a relatively full RAM with ZRAM enabled and swappiness at a high value (100) avoids exactly the following expensive scenario quite reliably:

Full RAM, which needs to be cleared in order to load a new app into it.

Remember swappiness at 100 will try to always move unused pages from RAM to ZRAM. This way we always have RAM available to load fresh apps in the quickest and inexpensive way possible.

Every OEM except samsung (which are not exactly known for their fabulous memory management) has ZRAM enabled.

Back when I started developing I read the articles about the needlessness and the wasted CPU-Power of ZRAM too. I used to disable ZRAM, when I started development, because the general consensus was that it´s not needed.

If we were talking about SWAP and not ZRAM I´d still agree and try to disable SWAP probably. SWAP should be avoided and it makes more sense to completely fill up the RAM before using SWAP. The story is however different with ZRAM.

After a lot of research I came to the conclusion that I won´t disable it any longer. I hope some people read what I typed out there and actually benefit from it.

It´s still in the morning, so if there are some mistakes please bear with me, I´m sitting here with my coffee trying to get my brain going :)