[Galaxy S 4 i9505 Original Android Development] LuigiBull23:
[MENTION=2019516]tuniel[/MENTION] is right in regards to sampling rates and how they affect CPU decisions but sampling_rate_screen_off ALWAYS matters regardless on the state. Here's why and [MENTION=4325945]ktoonsez[/MENTION] can chime in at any moment if my take on this is invalid.

Having a high sampling rate for screen off state will call for less CPU polling and usually pegs the frequency at whatever you have your screen off profile max Mhz set to. So ideally it would be more beneficial to use higher ramp rates for a higher screen off max rather than a lower frequency to reduce possible lag upon waking the phone. There are some advantages and disadvantages for low and High rates but it's not always best to use high rates on a low screen off max.

sampling_rate samples a frequency depending on the load and decides what to do with the CPU after the expiration of the user's set value. A higher value creates less polling of the CPU because it remains at the given frequency for an extended period of time before changing frequencies again. Other factors such as sampling_down_factor comes into play here as well but is not a concern when the screen is off because it does not use this parameter at all.

Besides that it's essentially the same concept during screen off states. When the phone awakes from sleep, the profile's screen off max mhz is activated and uses the frequencies available based on your set max. A higher screen_off_sampling_rate will increase sampling to that frequency and render the CPU at the specified frequency step until this value expires and then it can decide if if it wants to ramp up when you power on the screen.

This is why it makes sense to have a lower sampling rate for a lower end frequency step to reduce possible lag/delay upon turning on the screen. With lower ramp rates the CPU can check the load and react near immediately to change the current frequency for better responsiveness.

For instance, If your set max is 594 it may not be enough for some phones to turn the screen on in an exceptional amount of time so may not be as responsive towards the workload and can potentially lag out. Even if it does it you still face the possibility of a laggy UI.

You can have either high or low ramp rates for higher screen off max because the CPU will already have the required speed to respond (depending on what you use) and therefore won't need that much sampling time. However, I find it more convenient to use moderate ramp rates with high frequencies because when the phone awakes from sleep different operations are occurring at once and I personally want the phone to complete it's tasks as fast as possible to make for a faster race to the C4 state (deep sleep) WITHOUT allowing too much CPU polling.

Depending on how high you set it you're gonna want lower ramp rates to allow CPU to scale back down faster, otherwise it'll just be sitting at the given frequency consuming all the same power being supplied from that step. Rule of thumb is the higher the sample the longer it will remain at that frequency before returning to deep sleep, which is why I much prefer moderate polling of various frequencies when screen off is set high. I personally find it to consume less juice compared to pegging at a high frequency.

Such ramp rates are also beneficial during deep sleep state. Once you power on the phone while in deep sleep, screen off max mhz is now disabled at which point you're going to want CPU to sample the current frequency fast enough to ramp back up to an optimal frequency during this process to make for better responsiveness. When performing the same procedure while the phone is currently awake and attempting to complete a task it usually doesn't have the same effect because the phone is already awake and the component is already supplying some of that needed power to the CPU.

Aside from it possibly being caused by the governor/scheduler, this is usually where most people suffer from screen wake delays. It mostly occurs during deep sleep. If one's phone is sleeping too well then you can only imagine the delay.. The component needs to do too much to get the phone back into normal state and thus the lag is born..

That's why when people report such issues my immediate recommendation focuses directly on screen off max and sampling_rate_screen_off before looking into anything else within the profile. Setting screen off max to selected scaling max just allows for scaling up to your CPU max so sampling_rate_screen_off should still be accounted for.

Like I said, there are various aspects and these are not ALWAYS the cause but for the most part it is. If you see a profile with high sample rates and possibly a low screen off max then phone wake issues are likely due to those.

It's all about finding the right balance for yourself and others in hopes that the overall aspects of the settings being used remain stable for most people. It will never be perfect for everyone though. Just something everyone needs to accept.