Skip to main content

HFT-grade Linux infrastructure validator. Audits kernel, CPU, network, and clock settings against trading latency best practices.

Project description

โšก latency-audit

PyPI version Python Versions License: MIT Code style: Ruff Pre-commit CI Codecov

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 (isolcpus configuration)
  • NUMA topology awareness

Network

  • NIC Offloads (GRO/LRO/TSO should be OFF for latency-critical paths)
  • IRQ affinity
  • Ring buffer sizes

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/nikhilpadala/latency-audit.git

โšก Usage

Quick Audit (Read-Only)

latency-audit

Example output:

โšก latency-audit v0.1.0

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ                           KERNEL CONFIGURATION                            โ”ƒ
โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  โœ… swappiness = 0
  โŒ transparent_hugepages = always (should be: never)
  โœ… kernel.sched_min_granularity_ns = 100000

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ                            CPU CONFIGURATION                              โ”ƒ
โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  โœ… governor = performance (all cores)
  โŒ 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

latency-audit --category kernel
latency-audit --category cpu
latency-audit --category network

๐Ÿ”’ Security

This tool is read-only by design. It:

  • โœ… Reads /proc and /sys filesystem
  • โœ… Reads sysctl values
  • โœ… 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/nikhilpadala/latency-audit.git
cd latency-audit
pip install -e ".[dev]"

# Install pre-commit hooks
pre-commit install

# Run tests
pytest

๐Ÿ“ˆ Roadmap

  • --fix mode 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.

Project details


Download files

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

Source Distribution

latency_audit-0.1.2.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

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

latency_audit-0.1.2-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file latency_audit-0.1.2.tar.gz.

File metadata

  • Download URL: latency_audit-0.1.2.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for latency_audit-0.1.2.tar.gz
Algorithm Hash digest
SHA256 bbaf86c931947aceb15a9ab403c81bf78a8175409af4996ac33204111d1d7052
MD5 26190bcf69140b91465ba1ba11bafd3d
BLAKE2b-256 fcbbd9c25502a0b0357321f493d072fd620adc09407c4f205ce0b4b655c63ff6

See more details on using hashes here.

Provenance

The following attestation bundles were made for latency_audit-0.1.2.tar.gz:

Publisher: publish.yml on padalan/latency-audit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file latency_audit-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: latency_audit-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for latency_audit-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e73754a6fe8eb06fab6dfeb19d504237426b2d4523da43aa16e079936fedcf58
MD5 b3ab8dfb60883acb44fd25981462a092
BLAKE2b-256 adcebfc7cd7c56a758ba969f020b8dc20cf396b0a4d28947c7e5d1ec9115d419

See more details on using hashes here.

Provenance

The following attestation bundles were made for latency_audit-0.1.2-py3-none-any.whl:

Publisher: publish.yml on padalan/latency-audit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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