Default Kernel tweaks to fix stuttering and occasional crashes

I'm sharing some kernel tweaks that I found to eliminate lag, or micro-stutter to be more precise. Messing around with kernel settings can make your system unstable. It takes some experimenting to come up with a setup that runs without app crashes and reboots. Before I start let me clear a few things up:

- Many people claim that they don't experience lag on their phone. That's really great! Please be considerate of others that might be.

- I'm running CyanogenMod 10.2.0, Faux Kernel jfltetmo-aosp-faux-123-013m and I'm performing tweaks with TricksterMod v2.9.832.
I don't suppose you need to match my setup but if you understand what I'm doing you might be able to tweak your system in a similar manner.

- You might experience faster battery drain with this setup. The priority is on performance and stability.

- Phones can get really hot on a sunny day. It's winter here right now so I can't guarantee this will work well in a very hot environment. If you are experiencing crashes it's likely related to how your phone handles heat.

---------------
1) Lock the clock
I figured out by experimenting that the micro-stutter is caused by the CPU changing it's clock. I don't know why the Krait 600 is taking a time penalty when switching frequencies. This should not be happening and it's certainly not a problem with my Nexus 4 which has an older generation Krait CPU. Locking the CPU to a certain frequency made my experience fluid. I set my clock at 1.5GHz but slower frequencies certainly work well for everyday tasks. Be aware that it takes more power to run faster but the relationship isn't linear. If we take 1.5GHz as a base it would take 10% more power to run at 1.9GHz, it will take 10% less power to run at 1.1GHz and it will take 20% less power to run at 270MHz.

I set the governor to 'interactive'. I tried 'performance' but I couldn't verify that the phone was entering Deep Sleep. With 'interactive' the phone is locked at my set frequency and goes to Deep Sleep when it's not working.

The GPU governor works fine at 'performance'.


Click image for larger version

Name:	Screenshot_2014-01-21-12-28-07.png
Views:	168
Size:	212.1 KB
ID:	2530490


2) Increase the IO buffer
My IO buffer was set very low for some reason. 1024 or 2048 is recommended. I like the 'row' scheduler the best. 'deadline' is also recommended.

Click image for larger version

Name:	Screenshot_2014-01-21-12-31-29.png
Views:	185
Size:	209.9 KB
ID:	2530491

3) Shut off MP-Decisssion.
This is Qualcomm's thermal throttling. It slows down the CPU when it reaches certain temperature. This is a dangerous tweak so proceed at your own risk! What I do to protect my CPU is I shut off 2 cores instead. Most tasks nowadays can run on a single core but 2 cores really help multitasking. 4 cores aren't really needed. In the 'Specific' screen turn OFF MP-Decission and turn ON 'Intelli-Plug'. Then scroll down and press the 'Intelli-Thermal Control' button. Turn it ON, then in "Offline Cores' turn ON cores 2 and 3. The core number here is 0-based. The 'Core Offline Limit' I set at the lower value they had 50deg. I was experiencing crashes at little above 50 degrees. I'm not sure that's normal. To further protect the CPU make sure the Throttling is enabling on all cores.


Click image for larger version

Name:	Screenshot_2014-01-21-13-12-48.jpg
Views:	117
Size:	186.1 KB
ID:	2530493


Click image for larger version

Name:	Screenshot_2014-01-21-12-44-40.png
Views:	140
Size:	174.1 KB
ID:	2530492


Under high stress the temperatures raises to 50 degrees but stays there and the system is very stable.
Please feel free to share your results and ideas.