|
| 1 | +# Linux Benchmark Library - QWEN Context |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +The Linux Benchmark Library (LBB) is a robust and configurable Python library for benchmarking Linux computational node performance. It provides a layered architecture for orchestrating repeatable workloads, collecting rich metrics, and producing clean outputs. |
| 6 | + |
| 7 | +### Key Features |
| 8 | +- **Layered Architecture**: Runner, controller, app, UI, and analytics components |
| 9 | +- **Workload Plugins**: Extensible via entry points and user plugin directory |
| 10 | +- **Remote Orchestration**: Uses Ansible with run journaling |
| 11 | +- **Organized Outputs**: Results, reports, and exports per run and host |
| 12 | +- **Multiple Execution Modes**: Local, remote, Docker, and Multipass execution |
| 13 | + |
| 14 | +### Project Structure |
| 15 | +``` |
| 16 | +linux-benchmark-lib/ |
| 17 | +├── lb_runner/ # Runner (collectors, local execution helpers) |
| 18 | +├── lb_controller/ # Orchestration and journaling |
| 19 | +├── lb_app/ # Stable API for CLI/UI integrations |
| 20 | +├── lb_ui/ # CLI/TUI implementation |
| 21 | +├── lb_analytics/ # Reporting and analytics |
| 22 | +├── lb_plugins/ # Workload plugins and registry |
| 23 | +├── lb_provisioner/ # Docker/Multipass helpers |
| 24 | +├── lb_common/ # Shared API helpers |
| 25 | +└── tests/ # Unit and integration tests |
| 26 | +``` |
| 27 | + |
| 28 | +## Architecture Components |
| 29 | + |
| 30 | +### lb_runner |
| 31 | +- Core benchmark execution engine |
| 32 | +- Local metric collection system |
| 33 | +- Plugin execution framework |
| 34 | +- System information gathering |
| 35 | + |
| 36 | +### lb_controller |
| 37 | +- Remote orchestration engine |
| 38 | +- Ansible integration |
| 39 | +- Run journaling and state management |
| 40 | +- Lifecycle management and interrupt handling |
| 41 | + |
| 42 | +### lb_plugins |
| 43 | +- Workload plugin system with built-in plugins (stress_ng, fio, dd, hpl, stream, etc.) |
| 44 | +- Plugin registry and discovery system |
| 45 | +- Configuration models for each workload type |
| 46 | + |
| 47 | +### lb_ui |
| 48 | +- Command-line interface (CLI) and text user interface (TUI) |
| 49 | +- Typer-based command structure |
| 50 | +- Configuration management |
| 51 | + |
| 52 | +### lb_common |
| 53 | +- Shared utilities and configuration helpers |
| 54 | +- Logging and observability components |
| 55 | +- Environment variable parsing |
| 56 | + |
| 57 | +## Building and Running |
| 58 | + |
| 59 | +### Installation |
| 60 | +```bash |
| 61 | +# Create virtual environment |
| 62 | +uv venv |
| 63 | + |
| 64 | +# Install in different modes |
| 65 | +uv pip install -e . # runner only |
| 66 | +uv pip install -e ".[ui]" # CLI/TUI |
| 67 | +uv pip install -e ".[controller]" # Ansible + analytics |
| 68 | +uv pip install -e ".[ui,controller]" # full CLI |
| 69 | +uv pip install -e ".[dev]" # test + lint tools |
| 70 | +uv pip install -e ".[docs]" # mkdocs |
| 71 | +``` |
| 72 | + |
| 73 | +### Switching Dependency Sets |
| 74 | +```bash |
| 75 | +bash scripts/switch_mode.sh base # Base runner only |
| 76 | +bash scripts/switch_mode.sh controller # Full CLI with UI |
| 77 | +bash scripts/switch_mode.sh headless # Controller without UI |
| 78 | +bash scripts/switch_mode.sh dev # Development mode |
| 79 | +``` |
| 80 | + |
| 81 | +### Quick Start (CLI) |
| 82 | +```bash |
| 83 | +# Initialize configuration |
| 84 | +lb config init -i |
| 85 | + |
| 86 | +# Enable a plugin and run |
| 87 | +lb plugin list --enable stress_ng |
| 88 | +lb run --remote --run-id demo-run |
| 89 | + |
| 90 | +# Development Docker run |
| 91 | +LB_ENABLE_TEST_CLI=1 lb run --docker --run-id demo-docker |
| 92 | +``` |
| 93 | + |
| 94 | +### Quick Start (Python API) |
| 95 | +```python |
| 96 | +from lb_controller.api import ( |
| 97 | + BenchmarkConfig, |
| 98 | + BenchmarkController, |
| 99 | + RemoteExecutionConfig, |
| 100 | + RemoteHostConfig, |
| 101 | +) |
| 102 | + |
| 103 | +config = BenchmarkConfig( |
| 104 | + repetitions=2, |
| 105 | + remote_hosts=[ |
| 106 | + RemoteHostConfig(name="node1", address="192.168.1.10", user="ubuntu") |
| 107 | + ], |
| 108 | + remote_execution=RemoteExecutionConfig(enabled=True), |
| 109 | +) |
| 110 | + |
| 111 | +controller = BenchmarkController(config) |
| 112 | +summary = controller.run(["stress_ng"], run_id="demo-run") |
| 113 | +print(summary.per_host_output) |
| 114 | +``` |
| 115 | + |
| 116 | +## Key APIs |
| 117 | + |
| 118 | +### Runner API |
| 119 | +- `LocalRunner`: Core local benchmark execution |
| 120 | +- `BenchmarkConfig`: Configuration for benchmark runs |
| 121 | +- `MetricCollectorConfig`: Configuration for metric collection |
| 122 | +- `WorkloadConfig`: Configuration for individual workloads |
| 123 | + |
| 124 | +### Controller API |
| 125 | +- `BenchmarkController`: Remote orchestration controller |
| 126 | +- `RunJournal`: Run state and journaling |
| 127 | +- `RunLifecycle`: Run phase management |
| 128 | +- `StopCoordinator`: Interrupt and stop handling |
| 129 | + |
| 130 | +### Plugin API |
| 131 | +- `WorkloadPlugin`: Base class for workload plugins |
| 132 | +- `BasePluginConfig`: Base configuration for plugins |
| 133 | +- `PluginRegistry`: Plugin discovery and management |
| 134 | +- Various plugin-specific configs (StressNGConfig, FIOConfig, etc.) |
| 135 | + |
| 136 | +## Development Conventions |
| 137 | + |
| 138 | +### Logging Policy |
| 139 | +- Configure logging via `lb_common.api.configure_logging()` in entrypoints |
| 140 | +- `lb_ui` configures logging automatically; `lb_runner` and `lb_controller` do not |
| 141 | +- Keep stdout clean for `LB_EVENT` streaming when integrating custom UIs |
| 142 | + |
| 143 | +### Testing |
| 144 | +- Unit tests marked with specific markers (unit_runner, unit_controller, etc.) |
| 145 | +- Integration tests with different levels (inter_generic, inter_docker, inter_multipass, etc.) |
| 146 | +- Slow tests marked with `slow` and `slowest` markers |
| 147 | + |
| 148 | +### Code Quality |
| 149 | +- Uses mypy for type checking |
| 150 | +- Black for code formatting |
| 151 | +- Pytest for testing |
| 152 | +- Various linting tools (flake8, vulture, etc.) |
| 153 | + |
| 154 | +## Available Workload Plugins |
| 155 | + |
| 156 | +The library includes several built-in workload plugins: |
| 157 | +- **stress_ng**: CPU, memory, I/O stress testing |
| 158 | +- **fio**: Flexible I/O tester |
| 159 | +- **dd**: Basic disk I/O operations |
| 160 | +- **hpl**: High Performance Linpack |
| 161 | +- **stream**: Memory bandwidth test |
| 162 | +- **sysbench**: System performance benchmark |
| 163 | +- **geekbench**: Cross-platform benchmark |
| 164 | +- **unixbench**: Unix system benchmark |
| 165 | +- **yabs**: Yet Another Benchmark Suite |
| 166 | +- **phoronix_test_suite**: Phoronix test framework |
| 167 | + |
| 168 | +## Documentation and Resources |
| 169 | + |
| 170 | +- Documentation site: https://miciav.github.io/linux-benchmark-lib/ |
| 171 | +- API reference: https://miciav.github.io/linux-benchmark-lib/api/ |
| 172 | +- Workloads & plugins: https://miciav.github.io/linux-benchmark-lib/plugins/ |
| 173 | +- Diagrams: https://miciav.github.io/linux-benchmark-lib/diagrams/ |
| 174 | + |
| 175 | +## CLI Commands |
| 176 | + |
| 177 | +The main CLI provides several command groups: |
| 178 | +- `lb config`: Configuration management |
| 179 | +- `lb plugin`: Plugin management and listing |
| 180 | +- `lb run`: Running benchmarks |
| 181 | +- `lb provision`: Environment provisioning |
| 182 | +- `lb runs`: Run history and management |
| 183 | +- `lb doctor`: System checks and diagnostics |
0 commit comments