Skip to content

Performance

Status (v0.2.0): methodology and the benchmark tool exist; no measurement has been made yet.

KDAL adds a thin abstraction layer between userspace and hardware. The performance cost is one indirect function call per I/O operation through the driver ops table. The registry is consulted only when a file descriptor selects a device (or asks for its information); read and write then use the device cached for that descriptor (src/core/chardev.c).

tests/userspace/benchmark.c measures write/read throughput through /dev/kdal:

Parameter Default Description
Device uart0 Target device name
Iterations 1000 Number of write/read cycles
Block size 256 bytes Payload per operation
Terminal window
./benchmark # defaults
./benchmark spi0 50000 256 # SPI, 50K iterations, 256-byte blocks

Timing uses clock_gettime(CLOCK_MONOTONIC) for nanosecond resolution.

The targets are proposals, not derived from a measurement.

Metric Method Proposed target
Registration overhead Time kdal_register_*() in KUnit < 10 µs
Control-path latency Time single ioctl round-trip < 50 µs
Data-path throughput Sustained write/read via benchmark > 10 MB/s (QEMU ring)
Backend I/O latency Time single read/write op < 5 µs (QEMU ring)
Code churn LOC diff between backends < 15% of total
Porting effort New backend implementation time < 1 day for simple device

On QEMU, the ring buffer runs entirely in software. Results measure abstraction overhead without hardware latency:

Terminal window
insmod /mnt/shared/kdal.ko
./benchmark uart0 100000 64
./benchmark i2c0 100000 64
./benchmark spi0 100000 64
./benchmark gpu0 100000 64

On real hardware, measurements include actual bus latency. Compare KDAL-mediated I/O against direct register access, with a direct-access program still to be written:

Terminal window
# Direct I/O baseline (program to be written)
./direct_uart_bench 100000 64
# KDAL-mediated
./benchmark uart0 100000 64

Results will be populated after QEMU integration testing.

Device Block Size Throughput (KB/s) Latency (µs/op)
uart0 64 B TBD TBD
i2c0 64 B TBD TBD
spi0 64 B TBD TBD
gpu0 64 B TBD TBD
  • Mutex per registry - simple and correct; replaceable with RCU if profiling shows bottleneck
  • Ring buffer copy - QEMU backend copies through ring; real hardware backends bypass this
  • Single misc device - all devices share /dev/kdal; per-device char devices could reduce dispatch overhead
  • Replace mutex with rcu_read_lock() for hot-path device lookup
  • Zero-copy path for DMA-capable backends
  • Batch ioctl interface for multi-device operations
  • Per-CPU event rings to reduce contention