[OnePlus 8 / 8 Pro & 8T Cross Device Development] devsk:
So, I figured out why the battery life took a nosedive with this ROM compared to OOS 11. There are few things in this ROM specifically that seemed to have added to the bad battery life:

1. GPU overclock to 900Mhz from 587Mhz. I think we don't need to OC the GPU on this phone for silky smooth operation. I limited this back to stock and I see no effects in smoothness.

My request is that ROM writers provide a switch, named "Overclock GPU" in the Settings->Evolver somewhere, default it to false and let people who want to choose to OC, tick it.

2. AOD brightness is not adjusted. AOD is too bright. The reason for this is that brightness adjustment from apps is broken in 12. Its a private secure system setting and apps, even when granted the permission to change System Settings, can not change the brightness. I was lowering the brightness upon Display Lock using Automate to a lower brightness because I don't need a bright AOD, which is mostly used to see the time and see if any notification needs my attention. That seems to fail with A12.

This is a major battery sucker!

My request is that ROM writers provide a switch to disable Auto Brightness and lock the brightness to a custom level from the AOD settings.

I know about the "Extra Dim" setting, but its too dim for normal use and its not specific to AOD.

3. Memory writes. This ROM seems to be overly busy writing logging stuff to circular memory buffers, over and over again. Its a likely a bug somewhere that needs to be fixed but writing flooding logs to circular memory buffers repeatedly consumes a lot of CPU cycles as well as memory cycles, both leading to power usage.

So, turned off logging of several components using 'adb' commands to quieten down the memory writing.

4. There are some VM kernel parameters which are set wrong in this ROM. Particularly, the default usage of dirty_ratio and dirty_background_ratio. With small memory systems, these are fine to use but with a big memory system like OnePlus, the default settings accumulate too much dirty buffers for the system to dispose off in a reasonable time. This not only leads to more power usage because it blocks processes but also because it keeps the system awake longer. The inline IO can also cause micro-stutters in the processes which take on the job of the dumping these large dirty buffers to disk.

A way to solve this is to set dirty_bytes and dirty_background_bytes. This way you can limit the dirty buffers and dump them from time to time way sooner than, let's say 3GB (25% of 12GB RAM). A typical rule of thumb to keep any latency below a UI visible watermark(e.g. 200ms) is to see how fast the NAND is and use that calculate a value for dirty_bytes and dirty_background_bytes. I use a value of 15MB i.e. don't let more than 15MB of dirty buffers to accumulate.

function setupVmParams()
{
setAllDebugInfoLogsToError

# VM changes
echo 15000000 > /proc/sys/vm/dirty_background_bytes
echo 15000000 > /proc/sys/vm/dirty_bytes
}

function setAllDebugInfoLogsToError()
{
# top 25 debug/info/verbose polluters
for comp in $(logcat -d | awk '{if (($5 == "D") || ($5 == "I") || ($5 == "V")) { print $6}}' | sort | uniq -c | sort -n | tail -25 | awk '{print $2}')
do
comp=${comp%%/*}
comp=${comp%%\|*}
comp=${comp%%\[*}
level=$(getprop log.tag.${comp%*:})
if [[ "${level}" != "ASSERT" ]] && [[ "${level}" != "ERROR" ]] && [[ "${level}" != "WARN" ]]
then
echo "Setting the component ${comp} to WARN"
setprop log.tag.${comp%*:} WARN
fi
done

# top warning/error polluters greater than 500 count
for comp in $(logcat -d | awk '{if (($5 == "E") || ($5 == "W")) { print $6}}' | sort | uniq -c | sort -n | tail -25 | awk '{if ($1 > 500) {print $2}}')
do
echo "Setting the component ${comp} to ASSERT"
setprop log.tag.${comp%*:} ASSERT
done
setprop log.tag.ActivityManager INFO
setprop log.tag.lowmemorykiller INFO
}

function setBrightnessNormal()
{
settings put system screen_brightness_mode 1
settings put system screen_brightness 15
}

# use this instead of automate's screen brightness block, which is not
# working in A12
function setBrightnessLow()
{
settings put system screen_brightness_mode 0
settings put system screen_brightness 1
}

function onePlus8ProTricks()
{
# echo performance > governor &&

(cd "/sys/devices/platform/soc/3d00000.qcom,kgsl-3d0/devfreq/3d00000.qcom,kgsl-3d0" &&
echo 587000000 > max_freq &&
cd "/sys/devices/platform/soc/3d00000.qcom,kgsl-3d0/kgsl/kgsl-3d0" &&
echo 3 > max_pwrlevel &&
setprop log.tag.qdmetadata ASSERT
)
}

After doing all these tricks, I am now close to what I was getting with OOS11, which is about 26 hour run time with 5-6 hr of SOT (I have AOD on). This ROM is truly great now!