Skip to main content

lllqos: Linux Low-Latency QoS for Python

The Linux kernel provides the PM Quality Of Service Interface, which allows userspace processes to indicate acceptable wake-up latency. Processes seeking low wake-up latency (e.g., cyclictest) use this interface to tell the kernel the acceptable target latency (in microseconds).

The kernel documentation describes the interface as follows:

To register the default PM QoS target for the CPU latency QoS, the process must open /dev/cpu_dma_latency.

As long as the device node is held open that process has a registered request on the parameter.

To change the requested target value, the process needs to write an s32 value to the open device node.

This package provides a simple context-manager API low_wakeup_latency(target_value) that automates this. By default, the target value is 0.

On platforms other than Linux (or if the /dev filesystem is not mounted in the usual place), this context manager has no effect.

Example

from lllqos import low_wakeup_latency

# Standard use:
with low_wakeup_latency():
    print('Hi, but quickly!')

# Check whether lease was acquired:
with low_wakeup_latency() as lease:
    print(f'Lease acquired: {lease.acquired()}')
    
# Setting some nonzero goal:
with low_wakeup_latency(1000):
    print('Up to 1ms latency is acceptable here.')

A typical use-case is to combine this package with the abs-sleep package to achieve low-latency periodic activations.

from lllqos import low_wakeup_latency
from abs_sleep import periodic
import time

# tell Linux to minimize wake-up latency
with low_wakeup_latency():
  	# periodic wake-ups with a period of 500ms
    for t in periodic(0.5, align_secs=1):
      	now = time.monotonic()
      	print(f"periodic activation @ {t}s with {(now - t) * 1000000:.2f}µs latency")

NB: To achieve consistently low latency, you must run the Python interpreter with real-time priority (e.g., with theSCHED_FIFO or SCHED_RR scheduling policies).

See Also

Metadata

Release files for lllqos 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lllqos 1.0.0
File Size Uploaded
lllqos-1.0.0.tar.gz 5.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lllqos 1.0.0
File Interpreter ABI Platform
lllqos-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.1 kB

Release files / lllqos-1.0.0.tar.gz

Download URL lllqos-1.0.0.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5754ed6ce44cb1fc3caca7a2b94dff1d41afc92e9e91250243110dc6cd13bbef
BLAKE2b-256 checksum
How to use checksums
020b1b3dcc36ff939b604deabf5b7142a42944fc9eaca1c05797741ee9fc2125
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.16

Release files / lllqos-1.0.0-py3-none-any.whl

Download URL lllqos-1.0.0-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e968a8dcb4aeafdad79cd8d56c37e7b85bb736f6e46224870425d757f6b7a82b
BLAKE2b-256 checksum
How to use checksums
31889aca4c02761f9d7601c102e8391071886df28210f733ee80808374ab73d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.16

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page