Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Types and operations for the CPU cgroup controller.
Synopsis
- getProcessCPUQuota :: IO CPUQuota
- getCPUQuota :: Controller CPU -> IO CPUQuota
- data CPUQuota
- data CPU
- resolveCPUController :: IO (Controller CPU)
Operations on the CPU controller
getProcessCPUQuota :: IO CPUQuota Source #
Get the current process' CPU quota
getCPUQuota :: Controller CPU -> IO CPUQuota Source #
Read "cpu.cfs_quota_us" and "cpu.cfs_period_us" files into a CPUQuota.
For example:
| cpu.cfs_quota_us | cpu.cfs_period_us | CPUQuota | | ---------------- | ----------------- | ---------------- | | 100000 | 100000 | CPUQuota (1 % 1) | | 200000 | 100000 | CPUQuota (2 % 1) | | 50000 | 100000 | CPUQuota (1 % 2) | | -1 | 100000 | NoQuota |
A CPU quota is the ratio of CPU time our process can use relative to the scheduler period
For example:
| ratio | description | | ---------------- | ----------- | | 100000 / 100000 | (1) | | 200000 / 100000 | (2) | | 50000 / 100000 | (3) | | max / 100000 | (4) |
- : we can use up to a single CPU core
- : we can use up to two CPU cores
- : the scheduler will give us a single CPU core for up to 50% of the time
- : we can use all available CPU resources (there is no quota)
The CPU cgroup controller
resolveCPUController :: IO (Controller CPU) Source #
Resolve the CPU cgroup controller for the current process
Throws an Exception if the CPU controller is not able to be found, or when running outside of a cgroup