yashsingh1/xdaforums huggingface dataset:
[Redmi Note 2 General] jwchen119:
target_loads - 95 806000:78 1183000:88 1326000:93 1469000:95 1781000:97

timer_slack - -1

hispeed_freq - 403000

timer_rate - 15000

above_hispeed_delay - 15000 806000:25000 1183000:30000 1326000:30000 1625000:20000

go_hispeed_load - 200

min_sample_time - 10000

boost - 0

boostpulse_duration - 0

This is my current setting, but need more configuration, it can easily ramp down to 403 Mhz when idle, but I think 806 Mhz is more stable when any task is coming. So I have serious stuttering problem to solve.

You can use performance governor and set scaling_max to any freq to see what's the best working freq and idle freq.

Btw, [MENTION=2718533]Xmister[/MENTION] I have a question. There's two situation blow:

1. CPU use 6 cores @ 806 Mhz

2. CPU use 3 cores @ 1781 Mhz

Which one will be more power save?

I'm struggling between open more cores or drain out each core, there's no result so far...

With this setting, I got 3 hours of SoT and data connection "always on"
[Redmi Note 2 General] Xmister:
3 cores 1781 is probably better.

You also have some misconfiguration, sample time and above delay can only be a multiple of timer.

Tapatalk|Redmi Note 2
[Redmi Note 2 General] jajk:
[MENTION=5261119]jwchen119[/MENTION] timer_slack needs to be longer than timer_rate+min_sample_time+above_hispeed_delay to work at all.

There are many different opinions on how to setup the governor which is a good thing. That is how we learn.

I have edited OP with my findings on this topic. Take a look.

To ramp up faster (and avoid more cores kicking in to some degree) reduce above_hispeed_delay from default 20000. A single setting or multiple settings is a matter of choice.

To ramp down faster, reduce min_sample_time from the default 20000

To get the frequency scaling to work as intended with varying load, increase the timer_rate to 40000 to remove glitching.

Avoid too much ramping up and down through intermediate frequencies, that consumes power in itself.

Do not enable or alter any default Boost settings in the governor - all boost is handled by settings in perfservscntbl.txt

Less cores at higher frequencies is better within reason. The power consumed per core is logarithmic with increasing frequency so there is a point of negative returns when seeking the best battery vs performance setting. 1625MHz is my pick of a maximum desirable frequency based on temperatures reached in performance mode at different hard set frequencies. Antutu won't like it but the real world is what matters.

Come back with your experiences.
[Redmi Note 2 General] jwchen119:
I'm not very clear to what's the misconfiguration, actually I followed the guide from here Advanced Interactive Governor Tweaks; Buttery smooth and insane battery life so, I'm wonder which setting is wrong?

[MENTION=5952980]jajk[/MENTION] According to this reference, and I've take a look at source code, there's no limitation on "timer_slack needs to be longer than timer_rate+min_sample_time+above_hispeed_delay" and set it to -1 means defer timers indefinitely at all speeds.
[Redmi Note 2 General] jajk:
[MENTION=5261119]jwchen119[/MENTION] my apologies, I did not notice the negative symbol so all is good. Articles from different sources explain things in different ways. The logic behind the timer_rate+min_sample_time+above_hispeed_delay is only a recommendation, not mandatory and is because a sudden need for processing power may occur at the most inopportune part of the timing cycle i.e. a decision has just been made to ramp the frequency down and turn a core off.

Quoting from the excellent guide you linked to:

"timer_rate - If your idle frequency is not being exceeded much, adjust this downward in increments of 5000 until it is, then increase it by 5000. If your idle frequency is being exceeded often, adjust this upward in increments of 5000 until your CPU primarily stays at or below your desired idle frequency."

This is where I get 40000 from in my settings and it brings the load settings back into the normal expected range. Suddenly the governor behaves like it does on any other (non-MTK) phone.

Have you tested this aspect? What value for a stable idle with everything else set to default?
[Redmi Note 2 General] jwchen119:
[MENTION=5952980]jajk[/MENTION] I'm not trying to tune it from default value but takes [MENTION=5886947]soniCron[/MENTION] 's setting on Nexus 5x as base.

I once tune timer_rate up to 40000+ , and yes, I have the side-effect about slowly ramp down, it acted like the default settings.

Quote from the guide, "So try to get them as low as possible without the idle frequency being exceeded too much, as this inversely affects the snappiness and efficiency of your phone when you're not doing anything" I'm try to follow this guide that got this result.

Actually, I'm running bule's CM12.1 and doesn't have touch boost support, so I have not been so hard to find out the interaction between them.

So, back to your question, I must say that I didn't tried any experienced on keeping any value stay on default, as soniCron's conclusion described:

You must otherwise optimize your phone first!

I don't think our phone is optimized well from Xiaomi, without custom kernel, we can't control too much factor from the stock kernel itself...
[Redmi Note 2 General] jajk:
It seems that many brands using MTK chipset are relying on the same crude kernel made by a 3rd party and thereby inheriting the same faults.

If you dig into the boot.img of MIUI you will see our phone loads a fingerprint scanner driver along with about 10 other non-existant device drivers which demonstrates how optimized the ROM is!

By removing as much bloat, China spyware and downright stupidity from this phone it starts to perform O.K and would have been a better and longer selling flagship for Xiaomi. I first checked on custom ROMs available before buying this phone knowing that the factory ROM is diabolical so I can't complain now I have a US$139 phone with all the features and performance of a slightly more expensive phone from a proper manufacturer.
[Redmi Note 2 General] jajk:
I have changed over to sMIUI 6.1.21 to have a play but will go back to AOSP for sure.

My current init.d settings for AOSP work just the same in MIUI except there are a lot more background processes going on that bump the frequency so battery will not be as good.

I am thinking it could be the watchdog timer in these ROMs that writes to a file on a regular basis that is causing some of the problem? I wonder if it can be disabled?

Added a couple of extra tweaks since last time so script looks like this:

#!/system/bin/sh

echo 1183000 > /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq

echo 95 > /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load

echo 99 > /sys/devices/system/cpu/cpufreq/interactive/target_loads

echo 40000 > /sys/devices/system/cpu/cpufreq/interactive/timer_rate

echo 20000 > /sys/devices/system/cpu/cpufreq/interactive/min_sample_time

echo 15000 > /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay

echo 80000 > /sys/devices/system/cpu/cpufreq/interactive/timer_slack

echo 1781000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq

echo 300 > /proc/sys/vm/dirty_expire_centisecs ## 200 default

echo 500 > /proc/sys/vm/dirty_writeback_centisecs ## 300 default

echo 1 > /proc/sys/net/ipv6/conf/wlan0/disable_ipv6

[MENTION=2923435]barome[/MENTION] can you post the uboot.img preloader.img and boot.img from stock 7.1.3?
[Redmi Note 2 General] Xmister:
Anything less than timer_rate has no effect in sample time, just look at the source. The same goes for any delay.

scaling max freq might be overridden, better to use cpufreq_limited_max_freq_by_user in proc

Tapatalk|Redmi Note 2
[Redmi Note 2 General] barome:
[MENTION=5952980]jajk[/MENTION] here it is

https://mega.nz/#!aZkjFCqD!Z7RrQmc20q7omIwMTfmIU6KwiNr_VxfcITBbXh_K1RI
[Redmi Note 2 General] jajk:
Thanks [MENTION=2923435]barome[/MENTION]. Done my data for the month so can't download another whole ROM for these small pieces.

Have had better than expected results in slimming down the not so slim sMIUI . Might become the daily driver since it is hard to walk away from the beautiful camera.

If all goes well, I will list what can be stripped out and still maintain full functionality (if you have no interest in being part of the Xiaomi propaganda machine).

[MENTION=2718533]Xmister[/MENTION] I was wondering which way to go on the freq limit. Haven't seen it overrun to 1950MHz yet but I take your point. I will try the other way to see if there is an advantage.

Anyone had any success with manipulating /proc/hps settings? I am trying to change the default 1183MHz 2 cores behaviour that I don't think is coming from Interactive governor or perfserver.
[Redmi Note 2 General] DarthJabba9:
[MENTION=5952980]jajk[/MENTION] - so what are the current contents of youe /etc/perfservscntbl.txt ?
[Redmi Note 2 General] jajk:
On MIUI it seems like only the touch boost setting works in perfservscntbl.txt which makes more sense of some earlier question about the other settings.

On MIUI it is also much harder to get rid of periodic background activities that keep the cpu working.
[MENTION=5850987]DarthJabba9[/MENTION] I am still messing around with the settings but presently:

CMD_SET_CPU_FREQ, SCN_APP_TOUCH, 1326000

CMD_SET_CPU_CORE, SCN_APP_TOUCH, 1
[Redmi Note 2 General] DarthJabba9:
Thanks. Perhaps it could be lower?
[Redmi Note 2 General] DarthJabba9:
Surely, you mean 806000, and not 8066000?
[Redmi Note 2 General] Namaless:
For entropy to remove all lags the best way is 2048, 4096 :)
[Redmi Note 2 General] jajk:
[MENTION=5850987]DarthJabba9[/MENTION] I am first to overclock to 8066MHz or maybe a typo that I did not correct on the computer revision of this file.
[MENTION=3597029]Namaless[/MENTION] I noticed on stock settings that entropy pool was being depleted often and bumping up the figures fixes this but didn't try beyond 512 since I do not understand the full impact of doing so. Glad to say I don't have a perceivable lag to notice an improvement from.

In developer settings, if you enable Show CPU Usage and watch what threads are starting and stopping while also monitoring the cpu frequency, you will spot some offenders that are cranking up the cpu.

Please remember that these optimisations won't do much good if you have a heap of activity in the background that you may not be aware of. Take control over the running apps first.
[Redmi Note 2 General] jajk:
Just done a quick test and found that the entropy pool will still decline and possibly run dry for settings below 1024 2048 so thanks to [MENTION=3597029]Namaless[/MENTION] for recommendation.

I don't know why AOSP by vova.vafin doesn't rate a mention on xda? It had some bad press in early versions but is the most current and stable version I have found. Everything but camera HDR works. It is reasonably slim but can be slimmed down a lot more. V1.53 may have some issues so V1.52 is is the best bet. I am sitting on 1.50 until the next major release.

Here is a link to it (Google Translate is your friend):

http://4pda.ru/forum/index.php?showtopic=695717&st=3060
[Redmi Note 2 General] jwchen119:
[MENTION=2718533]Xmister[/MENTION]

I look back to my question today and found a formula about the power consume of CPU:

So, back to my question before, I asked about which one will be more power save.

Using this formula to solve it(I set C to 1 which means it is full loaded situation):

Let's determine.

Result is clear that situation 2 consume more power...

Reference:

Why P scales as C*V^2*f is so obvious by Taylor K. (Intel) on June 29, 2009
[Redmi Note 2 General] Xmister:
You might be right, I didn't do the calculation, when you asked.

Tapatalk|Redmi Note 2
[Redmi Note 2 General] jajk:
The maths is correct but does not take into account that the cpus will be on for half the time at twice the speed which is the point I was trying to get across:

With the big proviso that you are not running the cpu at very uneconomical frequencies, it can be better to run at higher frequencies for shorter periods - your maths calculation confirms this. It is also better to skip ramping up through intermediate steps which in itself consumes power in the switchmode voltage regulators and keeps the cpu on for longer. If you had a phone with the min-max governor and tried it out, you would be surprised how well that actually works.

The MTK6795M processor behaves very much like a 1.7GHz unit overclocked to 1.95GHz which leads on to a discussion on over-optimistic binning and the frequency limits of a 28nm manufacturing process. I don't want to go there......
[Redmi Note 2 General] jwchen119:
Thanks to remind me about the Δt.

I didn't take too many condition in that formula, because it will become too complicated.

When it comes to the real life task, smoothness and loading speed.

and as you mentioned, Δt might be another factor which affect the power consume.

Here's a test from Chinese to show how multi-CPU works in task:

Device: Lenovo A808t (MT6592 Octa-core 1.7 GHz Cortex-A7)

Using kernel tuner to control the core number in use and change governor to performance.

By his own app to record Choreographer to see multi-core working power

His app named, SFstatistics, which can record and statistics FPS in real time.

Here's the result:

As we can see, there's almost no effect in increasing cores more than 5 cores.

It reached the marginal effect, so this means if a task use more than 5 cores will be very uneconomical in this case.

So, what we can do is to find the sweet point between "more cores, lower freq" or "less cores, higher freq".

Since we can't control the cores in use by any apps or edit some of the file so far, what we can do is to control the ramp up time to effect it indirect.

so back to the Δt, if it really affect the power consume?

My answer is, it depends.
[Redmi Note 2 General] jajk:
Also depends on how well the O.S and app multithreads and the logarithmic increase in power consumption when pushing the limits of a die (i.e. overclocking) that is not taken into account in that equation.

May be able to limit cores by changing settings in /proc/hps. I have had a play with other settings in there looking for the default 2 core 1183MHz mechanism. Setting enable to 0 will disable hotplugging altogether and all 8 cores run full time so watch out for that one. Unless you have a means of monitoring how many cpus kick in during intense tasks, it is hard to know if reducing the core numbers is actually working. Any ideas how to record that?
[Redmi Note 2 General] jajk:
[MENTION=5850987]DarthJabba9[/MENTION] The script does not work. The cpu online setting is continuously written to by the O.S so anything you write there is overwritten. The only effect the script has is to limit frequencies. Also, whatever you write to cpu0 will be applied to all 8 cores.

Maybe possible to limit the cpu core numbers in the Hotplug settings found in /proc/hps to achieve what you want.

I have settled on 1024 2048 as ideal entropy tweak. It maintains around 50% available in the entropy pool under normal usage conditions.
[Redmi Note 2 General] jwchen119:
[MENTION=5952980]jajk[/MENTION]

Check your PM.

[MENTION=5850987]DarthJabba9[/MENTION]

You have to set /proc/hps/enable to 0 first to turn it into "manual mode" first, then tune the cores by any kernel tuner app which control the parameter "/sys/devices/system/cpu/cpu*/online"
[Redmi Note 2 General] jajk:
[MENTION=5261119]jwchen119[/MENTION] Thanks, will play.

Things still to find out:

1. How to control the 1183MHz 2 core default action that is not part of Interactive governor. Where is it coming from? Is this a perfserver setting we can define?

2. How to limit maximum core numbers hotplug will use? Is this controllable by /proc/hps/num_limit_xxxxxx settings?
[Redmi Note 2 General] jajk:
A bit of playing with the /proc/hps settings and I get odd results but maybe because I am running AOSP and I don't think it has the same functionality in the thermal and performance managers.

I can limit the use of cores by setting any of low battery, power serv, thermal or ultra power saving to 1 which does not seem right to me??? Surely if thermal or low battery are set to 1, this would limit cores only when those conditions are true?

Can someone on a MIUI ROM test this part of the script and report back if they have different outcomes?

#Tweak Hotplug

echo 2 > /proc/hps/input_boost_cpu_num # 2 default

echo 1 > /proc/hps/input_boost_enable # 1 default

# echo 1 > /proc/hps/num_base_perf_serv # dynamic setting - do not write to this one

echo 8 > /proc/hps/num_limit_low_battery # 8 default

echo 8 > /proc/hps/num_limit_power_serv # 8 default

echo 2 > /proc/hps/num_limit_thermal # 8 default

echo 8 > /proc/hps/num_limit_ultra_power_saving # 8 default

echo 1 > /proc/hps/rush_boost_enable # 1 default
[Redmi Note 2 General] DarthJabba9:
Thanks. Setting "/proc/hps/enabled" to 0 allows one to turn any of the cores on/off.

---------- Post added at 05:00 PM ---------- Previous post was at 04:46 PM ----------

What exactly is the result that one is looking for?
[Redmi Note 2 General] jajk:
The ideal situation would be to limit the amount of cores available to hotplug depending on the 4 different scenarios.

This may work correctly in MIUI by setting different values for each case but in AOSPv1.53 any and all cases limit the cores without the conditions existing.

So in MIUI if you set:

echo 1 > /proc/hps/num_limit_low_battery

Do the number of cores get limited to 1 only when a low battery condition exists?

Also does this drop the cores back to 1 if the cpu gets hot?

echo 1 > /proc/hps/num_limit_thermal

And...

Can you see a different behaviour disabling boost and rush boost?

Seems odd that if this core reduction is functional that all defaults are 8 cores????
[Redmi Note 2 General] jwchen119:
If you're running CM, you can unpack boot.img to edit the power profile to change the thermal. Or to flash [MENTION=3597029]Namaless[/MENTION] kernel which support power profile that you can edit the script in it.

What we can do is generally limit the cores and freq at the same time by editing :

echo X > /proc/hps/num_limit_thermal # this can limit the max core but not to disable the hotplug strategy

echo X > /proc/cpufreq/cpufreq_limited_max_freq_by_user # setting this to limit the max freq

Here's the source code, you can take a look at it.

https://github.com/omlet05/MediaTek...diatek/mach/mt6795/mt_hotplug_strategy_algo.c

https://github.com/omlet05/MediaTek...diatek/mach/mt6795/mt_hotplug_strategy_main.c

Mix these two setting ,power profile and interactive governor, we can now widely control the CPU.

EDIT:

Now I have an idea to do some hard test, just to ask you guys' view ;)

By using any screen record app, I can do exact the same task by playback the record.

So basically, I can now limit core/freq and change governor to performance and with the SFstatistics from Chinese to get the dropped frame.

By change the cores/freq ,I can get the relationship between the them and sort out a table or find out the sweet point.
[Redmi Note 2 General] Namaless:
Guys remember the device have one CPU and 8 core so setup only cpu0, the other are only virtual

---------- Post added at 04:13 AM ---------- Previous post was at 04:11 AM ----------

For the script change the governor or you cant see anything

Power save for battery save but the CPU stay to 806 instead to 403 (gg xiaomi for this ****)

On demand for performance without 3d games, or performance for 3d games
[Redmi Note 2 General] jwchen119:
Although the running time is not so long, but with proper interactive tweak, I can easily dive into 403Mhz, but sure, it depend on the task.
[Redmi Note 2 General] jajk:
It is real handy to limit to 1 core while setting up the Interactive load points - much easier without extra cores switching in and out.

I have just changed over to latest AICP for a trial. Tweaks initially get overwritten by scripts in the boot.img so I had to clean those up first. It does show that every custom ROM has its own set of peculiarities so we might be seeing things differently depending on which ROM we are on. There is no touch boost active in AICP but it is hardly noticable. I might see if it responds to enabling Interactive touch boost.
[MENTION=5261119]jwchen119[/MENTION] I did not manage to get any drop frames logging. I get the Go and Stop but no log!

Still no answer to whether or not the number of cores can be limited for each of the 4 cases: low batt, power serv, ultra power save and thermal?

AICP behaves like I saw in AOSP - any setting limits regardless of the conditions. I am beginning to think it is a function that doesn't quite work like it looks like it should -maybe the O.S writes the values into these settings on each condition eventuating and 8 is just the default when no condition exists?

[MENTION=3597029]Namaless[/MENTION] Thanks for your input and good luck with new (Qualcomm) phone I am guessing?
[Redmi Note 2 General] Namaless:
For sure this is my last xiaomi e mediatek device :D

---------- Post added at 12:47 PM ---------- Previous post was at 12:46 PM ----------

403 mhz you can use with interactive, the 806 min come from powersave governor, same for ondemand/performance stay all time to 1950... gg xiaomi kernel :D
[Redmi Note 2 General] DarthJabba9:
Which app do you use to examine what is going on with all these conditions?
[Redmi Note 2 General] jajk:
[MENTION=5850987]DarthJabba9[/MENTION] Best we ask [MENTION=5261119]jwchen119[/MENTION] what software he has - he has better stuff than me:D
[Redmi Note 2 General] DarthJabba9:
[MENTION=5952980]jajk[/MENTION] The ramdisk image in your custom boot cannot be extracted ("not in gzip format").
[Redmi Note 2 General] jajk:
[MENTION=5850987]DarthJabba9[/MENTION] That image is unpacked and repacked using latest Masterchef software downloaded from Needrom. It is your tool that is the problem as I can unpack and repack it again with no issue and it is exactly the boot.img I am running.

If using Masterchef, close Windows Explorer before unpacking or repacking to avoid getting file errors;)
[Redmi Note 2 General] DarthJabba9:
Well, all I can say is that I can unpack and repack every other boot image for this device. The boot image itself is unpacked, with a zImage and ramdisk.cpio.gz - but the ramdisk.cpio.gz cannot be extracted because it is not in gzip format.

Try unpacking the ramdisk.cpio.gz manually, using gzip + cpio. Here, it doesn't unpack - and it should. Any standard gzip + cpio image should unpack using any standard gzip + cpio binary.

PS: I am not using Windows; I am using Ubuntu linux - but that should make no difference.