[Android General] Kyuubi10:
If I answer the question of "what is a kernel" it wouldn't tell you much, besides there are enough other threads on XDA and other websites to answer this question.

The best question is "Why to use a custom Kernel?", which answers not only what it is, but also what it can do.

I like the way its explained here:

http://www.makeuseof.com/tag/consider-using-custom-android-kernel/

The next most important thing you need besides the custom kernel is an app to manage it.

Yes, you can change the code directly, but for most non-nerds an app tends to be best, providing a nice GUI to facilitate tuning.

And since I am aiming for this guide to be N00b proof, I am gonna provide as much information as possible.

There aren't many apps which give you control over all features of the kernel and, personally, I hate having to download multiple apps to control every feature of the kernel.

So these are my top 3 recommendations:

The original app from the kernel's dev. You know, the one made specifically for use with that Kernel?

Device Control [root] by Alexander Martinz (Not gonna explain why, just go and test it for yourself or at least look at the play store page)

Kernel Adiutor by Willi Ye (It has a nice material GUI, + Extra features such as tweaking low memory killer, sysctl & sysfs)

What I most found lacking in other kernel guides was a well organised and comprehensive list of things custom kernels can offer. And since there is so much a Kernel could offer I'm going to try to provide it in categories with a couple examples so you get a good idea.

If I there is anything not accounted for, you are welcome to reply to this post and I will be checking every day to expand with any new info.

So without any further ado:

Feature List

General Settings:

These are things which do not fall within any of the other categories to follow. They are things which are usually classed separately in the App used to control the kernel. Examples include but are not limited to

Fast Charge, Gesture (Knock on, Swipe2Wake), Color Calibration, Vibration Strength

.​

Advanced Settings:

These are similar to the general settings, but as the name suggests they are a bit more advanced and require a bit more knowledge/research to use effectively.

This includes

Entropy

(if you have no idea what this is look for Seeder App. The description of the App explains this very well.),

Voltage Control

(Ever heard of UnderVolting?),

TCP Congestion Control

(As a Networking Student I had no trouble understanding the technical documents about this, but knowing many who will be reading aren't knowledgeable of technical jargon I have included a nice link.)

http://androidmodguide.blogspot.co.uk/p/tcp-algorithms.html

As I know that there will probably be things I'm missing here, if you find anything which I have not explained, a quick google might be very helpful. Otherwise you are welcome to post a reply to this thread (even including the results of your Google if you need someone to explain it to you in a simple way.)

UPDATE 21/12/16: After getting my new HTC 10 I begun doing some research to understand the big.LITTLE configuration. It turns out that there are in fact some tweakable tunables for this. I won't be providing any recommended settings, since currently I am using a modded PnP which dynamically manages Kernel tunables for me, and as far as I know this is a feature unique to HTC.

But for those interested in finding out more here is a guide you could look through, if you want to learn more. The tunables are at the very end.

https://android.googlesource.com/ke...llow-dr/Documentation/scheduler/sched-hmp.txt
​

CPU Settings:

This is what you're most likely here for, this is the home of

Over (and Under) Clocking

.

But it also provides other very useful settings which might not look so simple at first. Here you can select a

CPU governor

(No guys, I will not list and explain what each one is, there are just too many and too many with stupid names. Instead I will leave you guys with a link to another guide specific about CPU Govs.)

http://androidmodguide.blogspot.co.uk/p/blog-page.html

While we're still talking about CPU Governors, there is a further option that you have if your app supports it.

You can tune the specific tunables for each specific Governor

, to get the best result possible and most suited to you. Whether you want more performance or battery savings from that specific governor.

Here you can also find toggles for

HotPlugging or its counter part CPUquiet

(Available only for NVIDIA CPUs I believe.) Hotplugging is simply the technology which decides when and which cores to turn off. CPUquiet is similar but rather than turning off the cores it simply makes the idle. The advantage is debated but the possibility is still there.
​

GPU Settings:

This one doesn't have many features (That I know of), it allows you to

Over/UnderClock your GPU

and also

change its Governor

.​

Memory Settings:

(EDIT: I have included a Memory settings after doing a bit more of research about it, since its slightly more complicated compared to the other settings. Although most of these settings are available in both custom or stock kernels they can be tweaked to experience performance and battery improvements. So I'll try to cover as much as I can.)

Here you can tweak anything related to

RAM and Cache

. For tweaking these settings I suggest using the app Kernel Adiutor which I recommended earlier.

Things which you can find in all kernels are

Low Memory Killer

(Out of memory killer function on Android.) There is no need for me to explain it, what it does is self explanatory, to better understand the tunables I will provide this link:

http://xdaforums.com/showthread.php?t=622666

You can also find tunables for

Virtual Memory (Caching parameters)

, which is part of "sysctl" in the kernel. Tweaking this improves cache management, helping improve load times of cached apps, battery saving by emptying cache less often etc...

Here is a link which will give you a description for each parameter: https://www.kernel.org/doc/Documentation/sysctl/vm.txt

But there are also things which are not active or part of all kernels.

zRAM

is part of stock, and some custom kernels disable it. While

KSM (Kernel Samepage Merging)

can be added by some customs.

zRAM

is just compressed RAM space. So you can store more in RAM by compressing the data you can fit more data inside your RAM.

Now obviously it is slower than actual normal RAM (since you have to encrypt and decrypt the data), but apparently it still is faster than using swap (which is in your internal memory rather than RAM). The principle works based on that Android prefers to keep data stored as much as possible in RAM to keep recently used apps running quickly. The more you use an app the more priority it has, therefore will stay in normal RAM, things you use sometimes but not very often are kept in zRAM (regardless of how full your actual RAM is), but since you don't use this very often you don't notice the performance hiccup of decrypting that data.

Then last case scenario things you barely use are kept in swap.

For you IT enthusiasts you should have realised already that "z" is the technology prefix for Compression. So it shouldn't come as a surprise that zRAM is compressed RAM.

KSM (Kernel Samepage Merging)

, this is simple, but it requires knowledge of some terminology. I will try to explain as simple as possible.

It allows the system to merge/share identical memory pages in RAM from different Applications/Processes. Thus it frees up RAM memory.

The only drawback to this is that it's up to your CPU to perform this task, therefore while it will increase performance it will also use up battery. But this is negligibly small (In my experience).

Therefore my recommendation is that if your Kernel offers this keep it turned on.
​

File System Settings:

The most desired setting available here is

I/O schedulers

. Again, I will not specify each scheduler since there are enough guides on the interbebs to give you all the info you need. On the other hand, I will leave you with my favourite of those guides.

http://androidmodguide.blogspot.co.uk/p/io-schedulers.html

The next most interesting settings is

Read Ahead Buffer

, this simply lets you choose how much data to load the buffer cache with. According to most benchmarks/tests the best value for this is 3 mb aka 3072 kb. This link gives you a better idea of it: https://broodplank.net/?p=788
​

Thermal Driver:

Here you can find toggles to manage overheating of the CPU and GPU. An example of which is

MSM-Thermal and Core Control.

I'm not gonna go into detail about these, since they are pretty self explanatory, and in my experience they both had descriptions beneath the toggles.

The most important thing to keep note of here is that only one should be on at any given time. If you turn 2 or more of these on together it may give you some issues. (It did with me.)
​

Tips & Recommendations

This is where as usual the writer gets to voice his opinion :)

Don't hate if you don't agree, just reply with your own opinion!! :D

I believe that any good custom Kernel should consistently provide some common settings.

We could say the minimum required to be considered a good custom Kernel.

Here is my list of basics:

General Settings:

Knock On (AKA double tap to wake)

Fast Charge

Advanced Settings:

Entropy

TCP Congestion Control

CPU Settings, all of it.

File System Settings, all of it.

Also my recommendation and tips for ideal CPU tuning and I/O schedulers.

FIrstly, CPU governors can be tuned to improve performance or battery saving. I found a good guide which explains the tunables:

http://xdaforums.com/galaxy-s2/general/ref-kernel-governors-modules-o-t1369817

My recommendations will not take into account all the possible governors, but obviously if you take into account my recommendations and swap my choice of governor for an improved version of the same, or a similar one, then it should be even better.

While regarding the I/O schedulers, they are extremely under documented in comparison to CPU governors. And I have not managed to find a guide on how to best tune the tunables for the schedulers, so I will not cover this. If any one reading has any idea about this, please feel free to share your knowledge with us lowly humans!! :D

Actual testing reports and comparisons among schedulers are extremely difficult to find. So I will only recommend ones which I have found enough articles for or ones which I have tested myself.

Now for my list of recommendations:

Ideal CPU Governor

For general use, with a battery saving focus I would recommend the Conservative governor. And if you need a bit more of performance then it can be tuned to provide such.

For performance I would use Wheatley. If unavailable, then Elemental X or Interactive will be fine.

N/B: I added wheatley as an update after using it for a couple months, it has a double focus on both performance and battery saving. It follows the idea of "race to idle", that since idle saves the most battery then dealing with processes quicker means more time spent in idle. Therefore it will scale up to higher frequencies than ondemand and interactive, and it will try to deal with all processes in as quick a time as possible.

But it also focuses on battery, and if a process queue is taking long it will resort to scaling down the frequency to save battery while still getting work done.

In my experience I have not felt it glitch, and its very stable. It has improved my battery life (not as much as conservative), but it also has allowed me to use my device at full power.

But as with anything, there's always a downfall, which for wheatley is that it is a rare governor to find in most kernels. Currently I only have it on skydragon kernel. Most other kernels do not feature this governor.

EDIT 29/02/2016: I have learned of a new way to tune the parameters for Interactive governor, for optimum efficiency, when wheatley governor is unavailable. Since Interactive is always available - it is one of the stock governors.

In short it is tuning the parameters to use and spend more time in efficient frequency steps, in order to save battery while keeping the performance as high as possible. Using the fastest frequency steps before a huge jump in voltage consumption.

The links which helped me do it are the following:

http://xdaforums.com/showthread.php?t=2769899

https://vjnaik.wordpress.com/2015/06/25/kernel-tweak-interactive-governor-paramaters-rooted-phone/

Ideal I/O Scheduler

For general use of your phone or tablet I would recommend using ZEN. It can provide good performance and better than average multitasking while having an average battery consumption. Being considerably better than ROW while at only slightly more battery intensive.

Obviously ROW is second choice, but if both of the above are unavailable, then B] FIOPS[/B] is a good replacement, ensuring an above average visual experience, good battery saving, at the expense of multitasking capabilities.

If battery isn't an issue, or you stream a lot of videos, then BFQ appears to provide similar experience to FIOPS plus excellent multitasking, at the expense of battery.

For Gaming, this was hard to find since there weren't any specific articles focusing on this, but from the descriptions and certain comments it appears that SIO provides a good experience. Others mentioned BFQ since it reduces lag.

For gaming you should absolutely avoid ROW and FIOPS since both have reported to increase lag during gaming.

For best battery saving the recommendation is definitely FIOPS. While it isn't the most battery saving scheduler (Noop is), it will provide the most battery saving while also efficiently giving you a great user experience.

For general multitasking the best one is BFQ. It will provide the best transfer rates (aka copy paste and install kind of thing), best for streaming & watching HD videos, and great for keeping loads of apps open at the same time.

N/B: I added ZEN to the list after using it for a couple months. At the time I first released this guide I could not find a kernel which offered this scheduler to test it. But after a while it started becoming more popular, and now it is easily accessible through most major kernels.

In my experience with it it has improved my multitasking slightly, while also reducing lag on general use. Battery increase unnoticeable.

Virtual Memory tuning

This one is a bit more complicated, and I have heard a whole bunch of stuff... Which is why I decided to test it myself and then come back to give you guys a report for it. The effects of VM tuning are not obvious at first glance and but affects the overall feel of the device. (Whether it feels like new, or sluggish etc...)

The main tunables you need to worry about are: Dirty Ratio, Dirty Background Ratio, Overcommit Ratio and Swappiness.

The guide I added above under "Memory Settings" will explain what each of these are.

Dirty Ratio & Dirty Background Ratio - Most people say that these need to be high, so that more stuff is stored in Cache. This will make your phone quick. Because cache is quick. But in reality this is only good advice if all you need to load on your phone is the system UI. Because as soon as you start loading different apps this cache fills quickly, and whenever you want to open an app/file/webpage that is not in cache, your CPU is tasked with both emptying whatever is filling up cache memory and load your new app into cache. Thus making multitasking a nightmare within the first day. A simple reboot of the phone is not enough, nor is clearing RAM (Note: Cache is not RAM).

Often the only solution to speed up your device is to Wipe Cache and Dalvik Cache from recovery every day. And for people with 150+ Apps installed which need to be optimized on boot, this means a lot of time is wasted.

My personal recommendation is to keep

Dirty Ratio at around 40

, which is double the stock value. Thus you have enough room before your phone freezes to free up cache. While

Dirty Background Ration at 10

, so that in the background without freezing the app you're currently in the kernel is constantly clearing cache. Allowing enough space for whatever you need to load.

Overcommit Ratio - While increasing allows more multitasking, I recommend leaving this at 0. It keeps RAM from completely filling up, thus avoiding "app xxx not responding" issues.

Swappiness - You have three kinds of fast memory on your phone, from quickest to slowest: Cache, RAM, Swap.

Swap is the last resort for your phone's memory. It is usually used when your RAM is nearly full. Swap is used for app data which is not currently being used, but part of the group of apps you use the most. (This is related to the Low memory killer, so for more information check that link. )

Since app data stored in Swap is stuff you don't use often it doesn't affect your phone greatly. But the more data kept in RAM, rather than Swap, the better.

Therefore after loads of try and testing I found that 40 is the perfect sweet spot. Allowing higher performance while keeping some data rather than completely deleting it when RAM is full.

This is my Guide to Kernels, if you find that it has helped you and would like to thank me remember to press thanks.

If you have any questions please do ask them, I'll answer the best I can.

If you would like to add more, dispute any of the things I said, give extra info on any specific thing which you believe deserves a more thorough breakdown, then go ahead, fell free to comment below.

Thank you for reading this Guide.