V
VernisOS
AI Engine

Auto-Tuning

The auto-tuning module continuously optimizes kernel parameters for best performance. It analyzes workload patterns and adjusts scheduler priorities, memory allocation, and IPC buffer sizes in real-time.

ai_tune — Run Auto-Tuning

Triggers an optimization pass on all tunable kernel parameters:

text
> ai_tune
Starting auto-tuning pass...

Analyzing scheduler:    tick_rate optimized 100Hz → 125Hz
Analyzing memory:       page_alloc batch size 8 → 16
Analyzing IPC:          buffer pool 4KB → 8KB
Analyzing I/O:          disk cache 32KB → 48KB

Results:
  Scheduler:  +12% throughput improvement
  Memory:     -8% allocation latency
  IPC:        -15% message transit time
  Overall:    +11% system performance

Auto-tuning complete.

Tunable Parameters

tick_rate50-500 Hz

Scheduler tick frequency — higher = more responsive, more overhead

page_batch1-64 pages

Pages allocated per request — larger = fewer syscalls, more memory waste

ipc_bufsize1-64 KB

IPC message buffer size — larger = fewer round-trips, more memory

disk_cache8-256 KB

Read-ahead disk cache — larger = fewer disk reads, more memory

context_switch1-10 µs

Target context switch latency — aggressive tuning affects stability

Tuning Algorithm

The auto-tuner uses a gradient-free optimization approach suitable for kernel space:

rust
// Simplified auto-tuning loop
fn auto_tune_pass(params: &mut KernelParams) {
    let baseline = measure_performance();

    for param in params.tunable() {
        let original = param.current();
        param.increase(10%);  // Small perturbation
        let improved = measure_performance();

        if improved > baseline {
            param.increase(10%);  // Keep going
        } else {
            param.set(original);  // Revert
            param.decrease(10%);  // Try other direction
            let alt = measure_performance();
            if alt <= baseline {
                param.set(original);  // No improvement
            }
        }
    }
}