yashsingh1/xdaforums huggingface dataset:
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
Not really.

The only possible effect would be if you have kernel-modifying / performance Magisk modules installed, some portions of this mod may overwrite settings changed by that module, or the Magisk module may overwrite settings from this mod.

Note that here's no real risk in this - you may just end up with a mixed bag of settings.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] dthabet:
Big fan of your script. Can you please consider adding a telegram channel and post updates and changelog to your script as they come?
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] rafe83:
I've been following this thread for awhile but have been slightly hesitant to try it. I'm running AOSIP/derpfest ROM with sultan kernel. Will I run into issues using this with custom ROMs and kernels? I've been trying to search, but seems like most people that have posted are using stock roms.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] rrrrrrredbelly:
I've used it with havoc & now ABC for the last year (?) with no issues.

Dan
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
Glad you like my script! Maybe someday I'll be on Telegram, but for now you'll just have to check in on XDA every once in a while. I don't update that frequently, and changelogs are in the 2nd post.

This script shouldn't cause any issues with custom ROMs or kernels.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] rafe83:
Cool. I'll give this a try when I get back home.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] rafe83:
Awe man. This script did wonders for my phone so far just in battery life. Thank you. :)
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
You're welcome. Glad you like it!
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] Sentheb3ast:
Android 10?
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] rafe83:
No on havoc rom with sultan kernel
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] bboynavi:
Oh man this is like magic!! Am I dreaming?? Or my pixel 2xl just lasted me a whole day. Thanks a lot developer, I can use my pixel 2xl again. Wish I knew about this script before I spent my money to buy oneplus for that better battery and nearly stock skin. Thanks for your work. I'd like to buy you a beer/coffee. :)
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
Happy to hear it!
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
New Version

Updated!

Version 33 (94pks33.sh) now available in the OP.

Change-log in 2nd post.

Enjoy!
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] crixley:
This is the best script on here imo. Doesn't make the display look like hot garbage and everything seems snappier and more responsive, especially touch latency. Great work!
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] Prey521:
Unfortunately, I had to stop using this script. It was causing a ton of lag on my phone. At first I thought that it was the kernel, but no matter which kernel I tried, my phone would just start lagging and stuttering out of nowhere, even after a reboot. I then deleted the script, rebooted and my phone hasn't lagged or stuttered at all ever since. Anyone else experiencing this?
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
I have not, but I'll try running without it for a while to see if I notice an improvement.

If I do notice any improvement without the script, I'll look into what may be going on.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
I'm not seeing any lag reduction when not running the script.

That said, the only thing I can think of that may be causing this would be the script disabling zram.

Please try the "34test" script I just added to the OP in which I left zram stock / untouched, and report back if this solves your issues.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] Prey521:
OK, I will give it a shot today. As a test, after I deleted your script, I gave Blackened Mod a try to see if it would also lag my phone, and it hasn't after 24 hrs of use. I will make sure to delete BM before I apply your script. FYI, I'm using Elixir Kernel 5.8.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
Thanks for the info.

I'm pretty sure BM leaves zram untouched, so that at least doesn't contradict my working theory...
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] warrencoakley:
So can you run both scripts then?
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
Yes, you can.

Note that my script will over-write BM for value parameters they both try to set.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] rodken:
I took the liberty of increasing the run delay to 4 minutes instead of the 2 to stay clear of any kernel app tweaks, other Magisk Modules or any another scripts way. Just my personal preference.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] Prey521:
So far so good....no stutters or lags all day today. I'm going to revert back to 33 to see what happens.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
Any further updates? If leaving zram on fixed your issue and re-using v33 caused them to com back, I'll release an update soon.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] rodken:
Were you experiencing any random freezes or just UI Latency issues?
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] warrencoakley:
What's the difference between 33 and 34?
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
34 leaves zram untouched (i.e. on, stock behavior), whereas v33 turns zram off. V34 is out of testing because it doesn't break anything (obviously) and seems to heave helped a few users' latency issues, but I haven't posted a full release note yet because some users are still evaluating if their issues come back if they revert to v33.

Feel free to try both and let me know if you have issues or a preference for either.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] Prey521:
Sorry, yes, when I applied 33, the stutter and lag returned. I didn't notice if any others have experienced the same thing. It's possible that it's specific to my device/setup. I'm back on v34 as of this morning, and all is good so far.

Both
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] rodken:
After using the v34 script for 18 hours, my device experienced random freezes. Nevertheless, after removing the script, all is back to normal.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
Did this not happen with v33?

That would be strange because v34 is "more stock-like" than v33 is...
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] rodken:
I took the liberty of jumping straight to v34 instead of using v33 first.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
10-4.

The script is really simple and shouldn't cause any issues like that, but sometimes weird stuff just happens.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] rodken:
After further investigation, I've come to a conclusion that the issues that occur with v34 script is device [A/B device] specific. I tested the v34 script on two other devices that are A-only Android devices without any problems.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
Slot configuration has nothing to do with this script - sorry.

It sounds like it IS device specific, though, which might make sense since some things in the script will just not take affect on non Pixel-2/XL devices.

Can you confirm the device that had the issue, and the ones that didn't?
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] rodken:
ZTE Zmax - Positive

LG G2 - Positive

Galaxy Nexus - Positive

2016 Pixel XL - Negative
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
That makes sense now.!

If you are going to use this script on something other than a Pixel 2/XL, please use the "generic" version in the OP only.

I'm not sure how the Pixel2/XL version will affect other devices as it is trying to set CPU, GPU, and other parameters that are specific to those devices.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] rodken:
Cool beans....
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
New (additional) Version

Updated!

Version 34 (94pks34.sh) now available in the OP, as an additional option for those who want zram to remain on.

Version 33 is still active and viable for those who don't want / need zram.

NOTE: Turning off zram (V33) should reduce latency, leaving it on (V34) will increase memory availability for recent apps, etc. like stock behavior.

Enjoy!
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] Prey521:
Are v34 and v34Test the same?
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
Yes.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
End of the Line

All,

It was a sad week - my Pixel 2 XL died! I had dropped it a week or two ago, and while it still seemed fine for quite a while, this week it stopped responding to touch at all - which obviously made it unusable. Complete wipe and re-flash... factory resets... all the kings horses and all the kings men... nothing could get it working again. I didn't realize how painful it is to be actually phone-less for a few days - we depend on these things way too much...

Anyways, there won't be any more updates to this mod for Pixel 2/XL. I hadn't really found any real-life improvements past v33/v34 in several months anyways, so there's at least that. I will leave the thread open so people can still get the latest files if they need them, but don't expect timely responses from me on this thread or any further debugging of issues since I no longer have hardware.

On a happier note, I have a shiny new Pixel 4 XL (already unlocked and rooted), so I may see some of you over there in the future!

Take care!
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] xFirefly93:
Congratulations to your shiny new Google Pixel 4XL, mate. See you over in the holy P4(XL) forum section instead from now on!

:highfive:
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] Prey521:
Just picked up a 4 XL myself! Can't wait for it to get in this week and start tweakin!
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] veetoe:
Anyone still using these lmk minfree values? Seems like they're really aggressive. Apps don't stay open, they have to reload. The ram hovers just above 2gb usage. I've tried lowering them quite a bit but then some weird things happen after a while, like apps won't open at all when you tap on them, unless I clear all of the apps from the recents, then they open until the ram gets too full again I guess? That's weird because the stock Google values are much much lower.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
I'm still using them as-is :)

You're right, though, that they are really aggressive. If you have many apps open and then use recents to go back to an older one, it will probably have to re-load. In my opinion, optimal LMK tuning is largely based on usage profile and preference. - what seems good to me is probably not optimal for many people.

I'm not sure why just lowering the values would cause the issues you're seeing when you do that, but my advice to you would be to just comment out the LMK lines in the script and reboot. Devices have enough RAM these days that aggressive LMK tuning is really of limited, if any, value. This is, I think, why the stock settings are so low.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] Lessaj:
I commented out the lmk section for that reason, using the rest though. :)
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
deleted
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
New Version!

Updated!

New version (94pks4)

Fixes a LMK / memory over commit issue where apps would stop opening when ram filled up, makes LMK much less aggressive overall, and made one or two very minor tweaks to vm parameters that seem marginally better in my evaluations.

File attached in OP, more descriptive change log in 2nd post.

Enjoy!
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
New Version!

Updated!

New version (94pks5)

File attached in OP, descriptive change log in 2nd post.

Enjoy!
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] Scott:
This script looks good. It touches on a variety of tunables. I used a very similar script in my custom ROMS.

One thing I also did in my script, I made it echo the date and time to a text file so I know that the script did or did not run. Might help you if you encounter an issue where the script seems not to be running.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
Thanks for the kind review and the suggestion!

I've been able to verify the script runs by just opening a kernel app (like EX) and verifying the changed settings have been updated, but I'll look into echoing out a time stamp in the next version (if there is one).

Any suggestion on where to write it out to? /sdcard? Same folder the script resides in (should be /Magisk/.core/service.d for most users)?

EDIT: Nevermind - I have the next version outputting to a file in /storage/emulated/0 since that's the top level people see in internal storage when opening a file explorer app, and is easier to write to as it (should) already be mounted r/w for everyone. Opening the file gives the date and time the script was executed, as well as a message indicating success if the script returns a "0" exit code and indicating failure otherwise.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
New Version

Updated!

New version (94pks6)

File attached in OP, descriptive change log in 2nd post.

Enjoy!

P.S. If for some reason you don't want the script to write a file when executing, you can continue to use the previous version (94pks5) still in the OP. Other than the run-check described in the change log, the scripts are the same.

You can delete the pks_script_result file from you internal storage (/storage/emulated/0) at any time... or leave it be for that matter. It will not affect the script running or any of your saved parameters either way. It will, however, be recreated (or overwritten) every time the script is executed with a new time/date stamp and success/fail message.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] henderjr:
Thanks for this! Odd but I don't see that file and I think I have everything correct. I did update Magisk to V16 this morning.

I do see this in the Magisk log.

02-28 08:29:15.826 600 959 I Magisk : * Running service.d scripts

02-28 08:29:15.826 600 959 I Magisk : service.d: exec [94pks6]

02-28 08:29:16.587 600 726 I Magisk : proc_monitor: zygote ns=mnt:[4026533937] zygote64 ns=mnt:[4026533938]

02-28 08:31:18.271 600 726 I Magisk : proc_monitor: com.google.android.gms.unstable (PID=5281 ns=mnt:[4026534136])

02-28 08:31:51.627 600 726 I Magisk : proc_monitor: com.google.android.gms.unstable (PID=8379 ns=mnt:[4026534124])

02-28 08:31:56.614 600 959 I Magisk : * Running module service scripts
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
Looks like Magisk ran it.

Can you scroll up in the files list shown on your second image? There should be a file named "pks_script_result" but I can't see whether it's there or not because your alphabetized list is scrolled down past where it should be.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] henderjr:
It seems to show folders first and then files so that's why I had it scrolled down to the bottom. Glad to know it ran according to the Magisk log at least
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
Hmm. That's odd as it's showing up on my device.

You can also check that the settings "took" by looking at some of your kernel parameters. If the io scheduler is noop and the read-ahead is 512 and zram is off it almost certainly fully ran.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] an21281:
For some reason V6 isnt working on my P2XL, V5 works and I have a copy of the older V3 and it works also when I place it in init.d or service.d (verified by checking setting in ex kernel manager although there is no pks_script_result file in internal storage) ...
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] qwer777:
I has the same result. No settings seem to apply at all.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
Sorry, everyone!

Short story - I think I borked the file through editing my test version with a Windows text editor (WordPad) before uploading it.

I just switched it out with the one directly from my device that is working (was modified in a android-native text editor).

Please delete the version currently on your device and re-download version 6 from the OP. Please let me know if this works... or doesn't.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] henderjr:
Damn editors! I've run into that a bit in my job.

Is V5 messed up too? That didn't work for me either an hour or so ago. But the latest V6 works! Thanks

View attachment 4433717
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
Yeah, I've run into it before at work, too. Rookie mistake... shows why "Senior Member" does-not-equal "Developer"!

v5 should not have been messed up as I never edited it on Windows.

The good news is v5 and v6 are the same in terms of the parameters they change - so if v6 is working you're getting all the v5 goodness :)
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
BTW... When you use v6, does it write out a file to your internal storage, and does it say "success"?
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] henderjr:
Oh yeah I forgot to look for it. Sure does!

View attachment 4433771
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
Sweet.

Thanks!
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] crossen0:
I've moved the file into the correct folder but I'm unable to change permissions on stock ROM. Help me out?
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
Assuming you're rooted since you got the file in /magisk/.core/service.d...

After that, you need to remove the ".txt" extension (rename) and change the permissions.

I use root explorer (file manager) to do both the rename and permission change, but any file manager that works in root should do the job. You want permissions to be 755 (rwx r-x r-x). This can also be accomplished through a terminal emulator by cd to the directory and then "chmod 755 filename". You can even rename the file in a terminal emulator; "mv oldfilename newfilename" is the syntax, I believe.

Let me know if you need more help figuring this out.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] otonieru:
Just tried it. Bootloop straight away. Delete the file in recovery. Back to normal
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] Juzman:
Hey Guys,

So in the script it has:

# lmk tweaks, we have lots of ram but apps are hungrier
echo 16384,32768,49152,65536,131072,262144 > /sys/module/lowmemorykiller/parameters/minfree;
# which is 64,128,192,256,512,1024 MB
# stock is 72,90,108,126,216,315 MB

Is there any reason why the first number is lower, but some are slightly higher, and a lot higher?

From my understanding it is: Foreground app, Visible app, Secondary server, Hidden app, Content provider, Empty app

Would we not want the foreground app to have the same or more, not less amount of ram?

Trying to read up on minfree. :)

Edit: Found this: Use lower values if you want more multitasking. Higher values if need more "free ram" for gaming etc.. I use 8,12,45,65,95,165 for more multitasking and for foreground apps to stay until ram becomes much lower. From this post: https://xdaforums.com/showthread.php?t=2751559
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
Sorry, I have no idea how this is even possible. There's nothing in the script that should be causing a boot loop - it doesn't even start changing anything until 100 seconds after phone is booted!

You're right on how it works.:good: LMK tuning is really a preferential thing. I like killing off empty unused stuff relatively quickly, but I know some people want everything they've opened in the last 3 days to be hanging around in recents. This is why my numbers are higher. Having the first number lower just means the app you are actually using at that moment will stay unkilled longer (e.g. it really doesn't matter). I believe that making the first several values linear, like it is on stock, seems to make the lmk algorithm run smoother and more predictable.

If you want to have stuff stay in the background longer, I recommend you just comment out the LMK values in the script, or just delete those lines.

I may delete them from future versions... seems I may be in the minority in how I like mine set up, and trying to make everyone happy... well I don't think the juice is worth the squeeze.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] Juzman:
I think I understand it right, I came up with: 15360,19968,30720,35328,58368,83712

stock is 72,90,108,126,216,315 MB | mine 60,78,120,138,228,327 MB | yours is 64,128,192,256,512,1024 MB

Which in turn I am assuming will improve multitasking, and also save *some* extra battery as the latter values aren't as high as yours, correct? Since it won't be killing off apps as often.

Basically took 12 off first two, and added 12 to last 4.
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] pkgnex:
Yes, your settings should allow better multi-tasking than mine, and will not kill apps off as often, thereby probably saving some battery. The only trade-off is that new apps may not open quite as fast if you already have a bunch of stuff open. All this is in theory, of course... the devices today are so fast that I'm not sure it really matters, and even when I'm heavily (for me) multi-tasking the free RAM rarely goes below 1024 MB and never below 750 MB so I'm not really even killing that many empty apps with my settings.

FWIW, your values are so close to stock that I wouldn't even bother changing them if I were you - just delete or comment-out the lines in my script. Based on your logic, the stock settings would result in even more multi-tasking and battery life than your proposed settings!
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] Juzman:
Ah, makes sense. I just used your script and (94pks6) and will see how it goes. :)

Added in the sweep2wake from EXMK and now I have no need for EXMK anymore. :)

Edit: Seems the script isn't running, interesting. It's in /magisk/core/service.d/ and chmod 0755.

Running script from ADB shell I get:

taimen:/magisk/.core/service.d # sh 94pks6

: not found

I even copied it into /magisk/.core/post-fs-data.d/ and tried running it from EXKM and got "no output".
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] otonieru:
Yeah, i know. Thats why i also wondering,

I know this phone is prone to stuck at boot as well, but i already learned howto see whrther it gonna stuck or gonna boot fine.

If after 5 bar movement (bar under the G logo) , the screen is dimming slightly. I know its gonna/supposed to boot. Else i know it will stuck at G logo.

But after installing this script. After dimming, it stuck there. Doesnt matter howany reboot i made. LoL

Luckilly i still have the magisk management recovery zip so that i can mount magisk folder and deletinh the script
[Google Pixel 2 XL ROMs, Kernels, Recoveries, & Oth] Pyr0x64:
Thanks for the script, installed it on my 2XL without issue this morning with a stock (march) rom, rooted and with flash kernel :)

I downloaded the 94pks6 file, removed the .txt extension, copied it to /magisk/.core/service.d using root explorer, set permissions to 0755 or rwxr-xr-x and rebooted.

magisk shows the script being run in the log, EX Kernel manager shows schedutil for CPU gov, noop for I/O, and the pks_script_result file is there and says:

To be honest, I can't tell the difference at the moment, but I'll see how it goes for a few days and how the memory management is