I've revisited this subject today since the described behavior is still present in 13.0. Based on the past conversation in #05470443 I have learned that the intent is to prevent sleep mode during a backup job, and that on top of conventional methods, Microsoft's modern standby initiative introduced 'a timeout after which the OS is allowed to no longer honor active power requests'.
Code: Select all
HKLM\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes
> 381b4222-f694-41f0-9685-ff5bb260df2e (Balanced)
> 2e601130-5351-4d9d-8e04-252966bad054 (Idle Resiliency)
> 3166bc41-7e98-4e03-b34e-ec0f5f2b218e (Execution Required power request timeout)
> ACSettingIndex = -1 (infinite)
> DCSettingIndex = 300 (5min)
VBR's SleepLocker calls PowerWriteACValueIndex/PowerWriteDCValueIndex to change both to -1 and then PowerSetActiveScheme to apply the change. It remembers the original values and wries them back once done. There are multiple problems with this:
- Changing global system state to solve an individual application problem is a very old antipattern.
- It fails the 'what if two programs did this' test, the outcome being -1 being permanently written to the OS.
- It does this even if the admin custom edits the values to already be -1. It doesn't bother checking and just does it.
- It does this on hosts using ordinary C3 instead of S0ix. It's unclear if these hosts even need this extra step.
- It does this on servers which do not have any sleep functionality.
I wonder how Microsoft expects backup software to operate under modern standby. Maybe it would be worth it to ask them. I wonder if VSS snapshots persist across sleep/hibernate and if Microsoft expects backup jobs to support pause/resume with disconnects.
All in all, the only visible artifact of the current logic are two power events for each backup session. I might have been overthinking it. Not attempting to detect what sort of system it's on and just doing it unconditionally is sloppy but also the least complex. It made me think back on Task Scheduler, which lets the admin decide - "start task only if on AC power (y/n)", "stop if switching to battery power (y/n)". It's tempting to just add more checkboxes, but in reality, there is only one good default and noone would probably want to change it.