
Rust and Systemd Services Sockets and Watchdogs Explained
Run a Rust service under systemd properly: a unit file with hardening, sd_notify readiness, socket activation for zero-downtime restarts, the watchdog heartbeat and journald logging.
Close to the metal: memory layout, no_std, unsafe, FFI and the microcontroller on your desk.

Run a Rust service under systemd properly: a unit file with hardening, sd_notify readiness, socket activation for zero-downtime restarts, the watchdog heartbeat and journald logging.

Find where a Rust program allocates and how much it holds. Use /usr/bin/time for peak RSS, heaptrack for Linux allocation timelines, the dhat crate for portable heap profiles and a counting allocator for tests.

Swap the global allocator with one line. Compare the system allocator, jemalloc, mimalloc and snmalloc on fragmentation, thread scaling, memory return and portability, and measure before switching.

Rust frees memory at compile-time-determined points using ownership and Drop, not a runtime collector. See what that buys in predictability and footprint, what it costs in design effort, and where reference counting fills the gap.

Rust is a supported language in the Linux kernel for new drivers and abstractions. See what that means, the toolchain and kernel configuration, the shape of a module, and why it is not a general Rust-everywhere switch.

Keep logic in a no_std library, put hardware behind embedded-hal traits, and run the library tests on your computer. Use fakes for pins and buses, and reserve on-device tests for what only hardware can show.

Arrange data for how it is read, not how it is modeled. Compare array of structs with struct of arrays, see why hot loops get faster with contiguous fields, and when the change is not worth it.

Bevy is an entity component system: entities are ids, components are data, systems are plain functions. See Query, Res, ResMut, Commands and schedules with a small runnable example and the ordering rules.

Both give you control without a garbage collector. Rust makes memory safety the default; C++ has the larger ecosystem and decades of code. Compare safety, tooling, interop and when to stay in C++.

Document every unsafe block with a SAFETY comment and every unsafe fn with a Safety section. Learn what a reviewer expects in them and how Clippy enforces the habit.

Find memory errors in unsafe Rust with AddressSanitizer, ThreadSanitizer and MemorySanitizer on nightly, and Miri for interpretation. Flags, build-std, output and limits.

Miri interprets your tests and reports undefined behavior in unsafe code: out of bounds access, use after free, bad aliasing and uninitialized reads. Here is how to run and read it.
We send one email when a new post is published. No spam.