Skip to content

v0.7.0

Choose a tag to compare

@InvictusNavarchus InvictusNavarchus released this 07 Sep 03:23
· 68 commits to master since this release
79c4d4f

The Native Rust Port

This release replaces the entire TypeScript/Bun implementation with a native, single-binary Rust daemon.

The primary goal of this port was to eliminate runtime overhead and make batmon adhere strictly to the observer principle: measuring system state must not meaningfully perturb the system. The new binary drops Bun and Node dependencies entirely, talks directly to kernel interfaces and D-Bus, and preserves 100% data and schema parity with existing databases.


🚀 Performance & Resource Footprint

Empirically validated over extended multi-hour side-by-side differential runs across reboots:

  • Memory Footprint: Median resident memory dropped from 28.4 MB (Bun/TypeScript) to 6.6 MB (Rust)—a >4× reduction, with peak memory reduced by up to 5.7×.
  • Thread Count: Reduced from ~15 threads down to 6.
  • Zero Child Processes: Eliminated all subprocess execution (busctl and notify-send spawns), saving ~1,440 process forks per day.
  • Sensor Path Caching: Sensor resolution in /sys/class/hwmon is now cached after initial probe rather than re-traversed every second, cutting ~3.9 ms of syscall overhead per tick while retaining automatic rescan fallback if devices drop or drivers load late (e.g. k10temp).
  • Deadline-Scheduled Cadence: Replaced setInterval with deadline-based sleep (sleep_until). Over a typical day, this eliminates roughly 7.5 minutes of cumulative tick drift caused by interval sleep accumulating tick execution latency.

🔔 Native D-Bus Integration & Alerts

  • Direct D-Bus Communication: Interacts directly with the system and session buses using zbus, removing dependencies on external CLI utilities (busctl, notify-send).
  • Bubble Replacement (replaces_id): Notification alerts now track IDs per family and replace active notification bubbles rather than stacking duplicates on the desktop.
  • Non-Blocking UPower Queries: Added a 2-second timeout to all UPower property reads. If UPower hangs or stalls, the daemon falls back to internal arithmetic rather than blocking the sample loop.
  • Lazy Notification Bus Reconnection: If the daemon starts at boot before the desktop notification daemon is alive, it cleanly degrades to journal logging and periodically retries connecting without crashing or spamming the session bus.

🛡️ Data Integrity & Differential Parity

The port underwent exhaustive continuous differential testing running side-by-side against the TypeScript implementation on real hardware through charge, discharge, and full system shutdown/reboot cycles:

  • Bit-for-Bit Cycle Accuracy: Across 1,430+ paired observations across two boot sessions, the cycle integration matched the TypeScript engine down to 12 decimal places (2.065114525, delta: 0.000000000000).
  • Database & Schema Parity: Verified against 7 starting database states and live historical databases. Both the flight-recorder (samples) and downsampled historical databases migrate cleanly and contiguously.
  • Safe Carry-Forward: Fixed a legacy edge case where battery removal or pack swapping would integrate missing battery capacity as discharge. The cycle count is now safely carried forward without artificial wear accrual.
  • Strict Numeric & Formatting Parity: Implemented exact IEEE-754 / JavaScript toFixed and rounding parity helpers to ensure stored floating-point telemetry and alert thresholds never drift or diverge on negative ties.
  • NaN & Infinity Guards: Alerts and units now rigorously validate non-finite numbers—sensor anomalies reporting NaN or Infinities can no longer trigger erroneous 0% critical alarms or bypass threshold checks.

📦 Upgrading & Installation

Upgrading is completely seamless. Your existing databases will be continued without data loss.

  1. Install Prerequisites: You only need cargo at build time. No Bun, Node, or runtime dependencies are required on the host system.
  2. Run Installer:
    ./install.sh
    • Installs a single compiled static binary to ~/.local/bin/batmon.
    • Cleans up legacy TypeScript runtime sources from ~/.local/share/batmon.
    • Preserves existing flight-recorder and historical SQLite databases.
    • Updates the systemd user service (batmon.service).

🛠️ Developer & Tooling Changes

  • Build and release workflows now use cargo-release instead of release-it.
  • Comprehensive property test suites covering state machine latches, hysteresis boundaries, and cycle accrual monotonicity.
  • Full CLI integration suite testing signal handling (clean WAL checkpointing on SIGTERM) and one-shot execution.