We all know controlling latency is the best way to control power consumption and still have a usable system. Putting the processor into deeper sleep states saves power, but it takes longer to come back to running. On pretty much all devices it’s all a trade off between time and power.
org.freedesktop.DeviceKit.Power.Latency is a DBus interface implemented by DeviceKit-power. It allows applications to request target latencies, for example a couple of seconds CPU-DMA latency for an IM application, or a few hundred microseconds of network latency for a multiplayer game. The lowest value of each latency type is used for the userspace->kernel interface, and then what do do is left for the kernel drivers themselves.
Use cases:
- I want my IM application to request 0.5s latency for messages
- I’m running an OpenGL simulation and want maximum performance, even on battery
- I’m running an SQL server for a credit card company, and want the server to request low latency CPU and network as any delay costs money
- I’m an admin, and want to change the power consumption vs. latency from cron scripts so it uses high latency during the night for maximum power saving, and low latency during business hours.
- I want high throughput when copying files, but want low throughput for downloading updates in the background.
- I want my power manager to set all latencies to lowest when on AC power
- I don’t want my users messing with latency settings
- I’m and admin and I want to be able to override all latency settings on my machines
Now, I want to build a system-activated service to manage this, so people that don’t care don’t have an extra process running. We can use PolicyKit to control all the authentication, and build up a service for applications and admins to use. This will be suitable for system services and desktop applications.
Why don’t applications use the PMQoS interface directly? Well, by providing a framework we can override requests by admin policy, and also control requests. You also can’t set latencies unless you’re the root user, which is not suitable for the desktop use case.
I’ve put an interface file up here.
Comments? Suggestions? Thanks.