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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lllqos-1.0.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lllqos-1.0.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file lllqos-1.0.0.tar.gz.

File metadata

  • Download URL: lllqos-1.0.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.4.16

File hashes

Hashes for lllqos-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5754ed6ce44cb1fc3caca7a2b94dff1d41afc92e9e91250243110dc6cd13bbef
MD5 f623570d0e6a8ac39c210efb42950105
BLAKE2b-256 020b1b3dcc36ff939b604deabf5b7142a42944fc9eaca1c05797741ee9fc2125

See more details on using hashes here.

File details

Details for the file lllqos-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: lllqos-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.4.16

File hashes

Hashes for lllqos-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e968a8dcb4aeafdad79cd8d56c37e7b85bb736f6e46224870425d757f6b7a82b
MD5 ffe30d7308e48c78455e2401eaf40c41
BLAKE2b-256 31889aca4c02761f9d7601c102e8391071886df28210f733ee80808374ab73d5

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page