latency-audit
The HFT Validator. A ruthless CLI tool that audits Linux infrastructure against Tier 1 High-Frequency Trading standards.
The Problem
Default Linux kernels are tuned for throughput (web servers), not latency (trading).
A single misconfigured setting can cost you:
| Misconfiguration | Latency Penalty |
|---|---|
swappiness > 0 |
+100µs (page fault) |
transparent_hugepages=always |
+50µs (compaction stalls) |
| GRO/LRO enabled | +30µs per packet |
| Wrong CPU governor | +200µs (frequency scaling) |
| C-States enabled | +500µs (wake-up latency) |
In HFT, 1 microsecond = $1M/year. These defaults are silent killers.
What It Checks
Kernel
- Swappiness (should be 0)
- Transparent Hugepages (should be
never) - Kernel preemption model
CPU
- Frequency Governor (should be
performance) - C-States (should be disabled)
- Core Isolation (
isolcpusconfiguration) - NUMA topology awareness
Network
- NIC Offloads (GRO/LRO/TSO should be OFF for latency-critical paths)
- IRQ affinity
- Ring buffer sizes
- UDP socket buffer drops (RcvbufErrors)
- NIC hardware discards (rx_missed_errors)
Hardware
- PCIe Link Width & Speed (validates NICs negotiated at max speed)
- Memory Channel Balance (detects asymmetric DIMM population)
Process
- Involuntary Context Switches (scheduler preemption)
- Major Page Faults (disk I/O detection)
Clock
- TSC reliability (
constant_tsc,nonstop_tsc) - Clocksource configuration
Installation
pip install latency-audit
Or install from source for the latest:
pip install git+https://github.com/padalan/latency-audit.git
Usage
Quick Audit (Read-Only)
latency-audit
Example output:
latency-audit v0.1.3
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ KERNEL CONFIGURATION ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
[PASS] swappiness = 0
[FAIL] transparent_hugepages = always (should be: never)
[PASS] kernel.sched_min_granularity_ns = 100000
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ CPU CONFIGURATION ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
[PASS] governor = performance (all cores)
[FAIL] C-States enabled (max_cstate = 9, should be: 0)
JSON Output (for CI/CD)
latency-audit --json
{
"score": 72,
"checks": [
{"name": "swappiness", "status": "pass", "value": 0},
{"name": "thp", "status": "fail", "value": "always", "expected": "never"}
]
}
Check Specific Categories
# System-level checks
latency-audit --category kernel
latency-audit --category cpu
latency-audit --category network
latency-audit --category hardware
# Process-specific checks (requires --pid)
latency-audit --category process --pid 1234
Monitor a Running Process
# Check if your trading application has any scheduler preemptions or disk I/O
latency-audit --category process --pid $(pgrep trading_app)
Security
This tool is read-only by design. It:
- Reads
/procand/sysfilesystem - Reads
sysctlvalues - Inspects NIC settings via
ethtool - Never modifies any settings
- Never requires root (though some checks are more complete with it)
Contributing
Contributions are welcome! Please read CONTRIBUTING.md for guidelines.
# Clone and install dev dependencies
git clone https://github.com/padalan/latency-audit.git
cd latency-audit
pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install
# Run tests
pytest
Roadmap
-
--fixmode with guided remediation - Benchmark mode (measure actual latency)
- Docker container for isolated testing
- Ansible playbook generation
- Integration with Prometheus/Grafana
License
MIT © Nikhil Padala
Built with obsessive attention to microseconds.
Metadata
Release files for latency-audit 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| latency_audit-0.1.4.tar.gz | 30.0 kB | With provenance | Details for latency_audit-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| latency_audit-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for latency_audit-0.1.4-py3-none-any.whl |
Total release size: 54.0 kB
Release files / latency_audit-0.1.4.tar.gz
| Download URL | latency_audit-0.1.4.tar.gz |
|---|---|
| Size | 30.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3ce501d11834e0f84a4e2c045d845f6434066783493331496e6e85038212f532
|
|
BLAKE2b-256 checksum How to use checksums |
e90baaa2e1b992b584ee3b831c63b37f10954d99098692374f13b3437b17b9ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 14, 2025.
Transparency logRelease files / latency_audit-0.1.4-py3-none-any.whl
| Download URL | latency_audit-0.1.4-py3-none-any.whl |
|---|---|
| Size | 24.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cf2ccbd764537ac3e29bb6ba42db8c48f912caba97cc11e04fd912c64e862c43
|
|
BLAKE2b-256 checksum How to use checksums |
b9543d548493026c03e5ea37c28645620edc1f8ad1a256e6071469b1451c8f15
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 14, 2025.
Transparency logSecurity for latency-audit 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for latency_audit-0.1.4.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 14, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.