[Galaxy S III Original Android Development] droidphile:
Know the STweaks Tunables

You have a custom kernel and an app to control different tweaks. Read below to have a fair understanding of all the sliders and drop-downs in the app plus read some faqs.

Q. "What's STweaks?"

A. It's an app developed by GM to provide a simple interface for various kernel tweaks.

STweaks works using /res/uci.sh interface. (Universal Configurator Interface). Ideally when you run /res/uci.sh config you get an xml file. The app render that XML file to an UI. (The xml is customconfig.xml in /res/customconfig directory)

Q. "Where are profile files (default, performance etc) stored in my device?"

A. /data/.siyah with extension ".profile"

Contents are in the format <tunable> = <value>

Q. "How come STweaks takes a little long to load every time? Other CPU tuner apps like SetCPU opens faster!"

A. Stweaks needs to query the values of ALL tunables from the active profile file, then set the UI elements (sliders, checkboxes, dropdowns, etc) to match the values queried. Only after these it can expose itself for you. So yeah! Some time is needed.

It loads in about 2 seconds now.

Q. "So every tunable possible with SiyahKernel is included in STweaks?"

A. NO. That would make the app complicated and while some users like to have lotttsa tweaks in the app, some users prefer the opposite. So to be fair, STweaks will not be cluttered with way too many options.

For users who know what they're doing, there are scripts, and kmemhelper.

Q. "After flashing a new version of Siyah, I can't see STweaks in my app drawer. Help!!"

A. Using a Root File Explorer, copy STweaks.apk from /res directory to /system/app. Set permissions rw- r-- r--

Q. "I find that after flashing a new kernel version, while adjusting some tunables there's no effect."

A. In the app, under EXTRAS Tab, hit "Reset settings to default". Now reconfigure all your settings. Should be fine in most cases.

Q. "Sometimes, after flashing a new kernel build, i see all my settings are reset to kernel defaults. Is it normal?"

A. YES. It's just so that profile files contains all the tunables matching config XML in the latest build. If resetting is not done, some settings will not work.

Q. "Does that mean - every time I flash a new kernel build, I need to reset settings?"

A. NO

Q. "What should I change in STweaks to have best battery/best performance?"

A. Read below to know what each tunables do. If you still don't get it, don't change anything. Trust defaults. All will be good.

1) CPU Tab

Gentle_Fair_Sleepers:-

This is a CFS tweak. CFS aka Completely Fair Scheduler is your default Task Scheduler. Task Scheduler is responsible to manage task executions - decides what task to execute next from a queue. CFS scheduler tries to fairly distribute the CPU time among all tasks in such a way that each of them gets the same amount of the virtual run-time. CFS maintains two arrays - active and expired. Tasks once served from active array are placed in expired array. When there are no more tasks in active array, the two arrays are swapped. Sleeper Fairness means to consider sleeping tasks similar to the ones on the runqueue and credit the sleepers in a way that it would get CPU as if it were running. With Gentle_Fair_Sleepers enabled, sleeping tasks will get a little bonus time w.r.t to their virtual run time. While this may seem fair in some cases, disabling this tweak may possibly improve UI responsiveness:- may be because sleeping tasks are not given additional priority and the task that's responsible for UI do not sleep while screen is ON.

* Arch_Power:-

Another scheduler tweak. Helps in using specific ARM topology functions instead of generic functions. Benefits may include idle higher number of threads in a core, etc.

* CFS Tweaks:-

Three options which sets different value for your task scheduler's a) Minimum Granularity b) Latency c) Wake-up Granularity

A new "epoch" or a new time origin begins when scheduler swaps active and expired array.

Latency is the length of an epoch in nano seconds.

Minimum Granularity is the granularity of one epoch.

Wake Up Granularity is the ability of tasks being waken up to preempt the current task (5 ms by default). The larger the value the more difficult it is for the task to force the preemption.

- Samsung Defaults:- Leave it as Samsung defaults if you want higher benches.

-Linux Kernel Defaults:- My fav.

-Thunderbolt Scripts Defaults:- Pikachu's tweaks are aggressive low values for parameters. May improve UI responsiveness.

CPU Idle Modes:-

Leave it as Idle+Lpa. AFTR seems to be a difficult world to conquer for i9300.

* Smooth Scaling Level:-

Leave it as 1800mhz (which disables smooth scaling) if your governor has the parameter "freq_step" (ex: Pegasusq). Otherwise, the two concepts may conflict. Use smooth scaling for other supported governors. CPU driver scales CPU to frequency as defined by Smooth Scaling Level before jumping to Max Frequency.

Sched_mc:-

Leave it disabled = 0. 1 will overload first core, 2 will try to save power by biasing task-wakeups to semi-idle core.

CPU Undervolting:-

[Courtesy Andreilux for the info] 32 nm Exynos 4412 on our device decreases the need for higher voltages for transistors to switch and decreases voltage leakage. So they actually successfully switch more of the time compared to SiON on Galaxy S2 i9100 where leakage was big enough to not make a transistor switch and crash the system. In short, this is why GS3 supports higher UV compared to GS2. You might be lucky enough to UV more than 200mv on certain frequencies. Try on own risk.

Max CPU Lock:-

Defines no of cores to be used along with Pegasusq governor. Leave it quad core. You have beast of a phone. This parameter actually changes the max_cpu_lock parameter of your governor - pegasusq or lulzactiveq.

CPU Governor:-

Use Pegasusq.

CPU Max Frequency:-

Sensible OC for our device is 1.5 Ghz. You can try more and see what happens.

CPU Minimum Frequency:-

Use 200 or 100.

2) CPU_UV Tab

Like SetCPU or voltage control, sets voltage per CPU frequency. Note that the values DO NOT represent the actual voltage levels on the frequencies. If you UV in Stweaks and also use SetCPU to set voltage levels, SetCPU will over ride Stweaks.

3) GPU Tab

* Mali Touch Boost Level:-

If this option is enabled to any steps, when you touch on the screen/press soft back or menu keys/press homebutton - GPU voltage is set to the GPU step that match the step set by you here and frequency is set to that step. This may helps in better responsiveness of unlocking via lockscreen, etc. Note that, this doesn't mean GPU is locked to that forever. After one second, depending on thresholds and stepcounts, soon GPU is clocked down or up.

If Mali Touch Boost Level is disabled, GPU resumes at lowest frequency (your first step).

GPU Frequency Steps:-

Now we have frequency steps taken from Korean sources, as hard coded in clock-exynos4212 file. You won't find a formula to calculate valid frequency steps. (Unlike i9100 for which any GPU step was 800 divided by an integer)

GPU Voltage Levels:-

You may be able to UV a little more compared to GS2 if your ex device was GS2. Try and see. (Thanks to 32 NM SoC). Remember that you will know UV was too much only while GPU is being heavily used - like gaming.

GPU Thresholds:-

If you're not sure about this, use default thresholds. Wrong thresholds can cause lags.

* GPU Stay Counts:-

Stay count is the number of Seconds GPU should stay at a frequency level before it can scale up or down, overriding "load exceeds threshold condition". To avoid any possible stutters in gaming, use staycount = 1 second for the last step. May be for 4th step too, just to be sure.

If you don't find StayCount interface in the app, use script.

echo "0 0 0 0 1" > /sys/class/misc/mali_control/staycount_control

From left to right, each digit represents StayCount for lowest to highest GPU frequency steps.

4) AUDIO Tab

Speaker Tuning:-

Check to enable better bass response on speakers. Note that GS3 speakers don't play well with bass (even with open source audio HAL developed by codeworkx for CM10. So if you find sound distorting on speakers, uncheck this option instead of trying to play with some equalizer.

Speaker Amplification Offset:-

Default zero. Increase to amplify speaker volume. At level 5 or 6, speaker is most likely to distort playing ringtones/sounds.

Headphone Amplifier:-

Volume boost for your headphones. Level 0 = -57 dB. Level 63 = +6 dB which is the hardware maximum. Please take care of your hearing.

3D Effect:-

Stereo expansion may tighten the stereo field. In general, there are multiple techniques to achieve surround effect/3d effect/stereo expansion effect.

3D Effect Gain:-

Valid only if 3d effect is enabled. Higher value may not sound pleasant to most ears. 2-4 should do.

EQ Presets:-

Use inbuilt presets or use graphical equalizer bands to tune the 5 band equalizer.

Graphical Equalizer:-

The five band equalizer(with a range of -12dB to +12dB) is a hardware equalizer. So it controls all the sound coming from your headphones. Software equalizers such as inbuilt EQ of powerampp can only control the sound output 'formatted' by this 5 band h/w EQ. As you know, the first two bands - Lows/Bass. Middle one - Mids/Vocal and last two bands for - Highs/Treble.

Negative Digital Gain:-

Or dynamic range. Increase this to prevent distortion. It defines how much volume is to be digitally reduced from headphone amplification level.

FLL Tuning:-

Aka Anti Jitter is an audio enhancement technique as an internal clock optimization to reduce noise and produce a better quality sound.

DAC Oversampling:-

Increases dac oversample rate for a 48 khz rate and produce better outpund sound.

DAC Direct:-

Aka DAC ME, Bypass analog channels and redirect sound directly to output.

Mono Downmix/Force Mono:-

Force mono sound even if source is stereo.

5) SCREEN TAB

* MIN_BL, MIN_GAMMA, MAX_GAMMA:-

In simplest form, set this higher to have lower brightness at bright conditions on automatic-brightness settings. And vice-verse.

We have lowest brightness for a brightness level read from sensor less than min_bl. Any level higher than min_bl will be linearly mapped to min_gamma:max_gamma to interpret brightness of the display. Difference between min_gamma and max_gamma along with their values affect overall brightness response curve.

mDNIe Sharpness Tweaks:-

Makes thin fonts more readable. You're most likely to see weird display if you disable this option.

mDNIe Negative Toggle:-

If this is enabled, quickly pressing home key four times will invert all the colors on your scree. Useful for ex: Reading a webpage in the dark which has white background by default. By inverting colors to make it black, your eyes will strain lesser, plus it saves battery in such cases.

Touch Boost Level:-

Defines the frequency to which CPU is instantly ramped up to when we touch the screen. Advantage? UI responsiveness. Setting this too low might be a v bad idea on some devices.

Slide2Wake:-

If enabled, slide on screen in a straight fashion from left to right to wake your device. Helps prevent wear down of physical home/power buttons. If in doubt this drains more battery, leave it disabled.

FB Early Suspend Delay:-

Early suspend delay to run CRT off animation. If you're sure that Settings > Developer Options > Windows Animation Scale is 1x or higher (not 0.5x or off) and still can't get CRT-off animation to work, set this param to 100 ms or so.

6) MISC TAB

Android Logger:-

Enable disable android logger. Logger hardly uses any extra battery, and will be very useful if to pull a log after a crash or freeze. Leave it enabled.

* Insecure Adbd:-

Enables to run your Android Debugging Bridge Daemon (adbd) in root mode by default. Use "adb remount" command in a terminal to mount /system as r/w.

I/O Scheduler:-

Use any among deadline/sio/noop.

* Zram Size:-

Compressed swap space aka compcache aka zram allocates defined amount of space from your physical RAM as compressed swap space. You can debate all along to see if zram is useful on a fast device like GS3 with a fast flash storage inside. If in doubt, disable this option.

Notification LED Behavior:-

Force blinking/fading of notification LEDs. Useful for Sammy based roms. (aosp roms has blinking/fading setting inbuilt).

AC Charge:-

Charge current from your wall charger. Increase the value for faster charging at own risk. If you see currentwidget app displaying only 800/1000 mA (when you have set 1200 mA in stweaks) while connected to car charger - it's because the charger can not output more current than that.

USB Charge:-

Charge from usb charger. Increase at the risk of possible damage to PC motherboard. (if it's an old board)

Discrete Wakelock Status:-

Helps betterbatterystats app to report deleted and non-overlapping wakelocks. You may see new wakelocks like your mailclient-inbox-sync, etc if this option is enabled.

Remove Root:-

Some apps detect root and refuse to work if found (certain banking apps for example). To remove root, click this button, run your app and re-enable root when you're done.

Auto Install Root:-

Tries to install superuser apk and binary. If it fails, download latest superuser flashable zip from here and flash in recovery OR download SuperSU from playstore.

6) DUALBOOT TAB

Reboot into 2ndRom Utils:-

Reboots to alternate recovery where you can configure and play with dual boot options. This doesn't change your cwm recovery, but just runs an alternate recovery.

Reboot into 1stRom:-

As it says, reboot to 1st rom without displaying a timeout.

Reboot into 2ndRom:-

As it says, reboot to 2nd rom without displaying a timeout.

No boot logo:-

Check this to disable Siyah bootlogo displayed during dual-boot rom selection time out. (If you're dual booting, logo will be shown anyhow)

Default Rom:-

Specified the default rom (among 1st and 2nd) to which device will boot into, if no keys are pressed during boot. If 2nd rom is default, pressing home/vol down keys will boot 1st rom.

Hijack Recovery:-

We know the second rom utilities aka embedded recovery is a part of the kernel - it holds the same partition as kernel. You can use this button to flash the embedded recovery to main recovery partition (overwriting your existing recovery) so that 3 button method/booting to recovery using extended power menu will take you to Siyah recovery. This is NOT a dangerous operation. You can flash cwm/twrp recovery anytime if you need another recovery.

7) EXTRAS TAB

Reset Settings to Default:-

Reset the profile file, and resets all values in device files to kernel defaults.

Check for Updates:-

Checks and downloads a new build.

Flash Kernel:-

Flash a .tar kernel. Alternative to Mobile Odin!

* Indicates tunables removed from STweaks as of now.

Flashable Zips

Update: Find sample Stweaks Profiles as flashable zip here. http://xdaforums.com/showthread.php?t=2034981. Profiles after flashing will be available in the profile app.

Here are 5 Governor Tweaks scripts as flashable zips.

Flash remove_governor_tweaks zip to remove init.d script that contains governor tweaks. One governor zip can be flashed over another and it will just replace the previous. All governor tweak scrips contains tweaks for pegasusq and luzactiveq. Gamerstweaks is also a governor script that's similar to extremeperformance script but does some additional GPU tuning (for which there is no interface in Stweaks) to enhance gaming experience.

Since order of execution is like this:-

1) STweaks applies its settings

2) Init.d scripts are executed

3) Apps such as SetCPU applies its "set on boot" options,

Script applies the tweaks to the governor selected in Stweaks (depending on if it's pegasusq or lulzactiveq). So if you want pegasuq tweaks to be applied, make sure pegasusq is the default governor in stweaks, and same for luzactiveq.

I will keep updating zips while new kernel builds are released - if it changes any tunable.