Subsecond: A runtime hotpatching engine for Rust hot-reloading

https://news.ycombinator.com/rss Hits: 10
Summary

§Subsecond: Hot-patching for Rust Subsecond is a library that enables hot-patching for Rust applications. This allows you to change the code of a running application without restarting it. This is useful for game engines, servers, and other long-running applications where the typical edit-compile-run cycle is too slow. Subsecond also implements a technique we call “ThinLinking” which makes compiling Rust code significantly faster in development mode, which can be used outside of hot-patching. §Usage Subsecond is designed to be as simple for both application developers and library authors. Simply call your existing functions with call and Subsecond will automatically detour that call to the latest version of the function. for x in 0..5 { subsecond::call(|| { println!("Hello, world! {}", x); }); } To actually load patches into your application, a third-party tool that implements the Subsecond compiler and protocol is required. Subsecond is built and maintained by the Dioxus team, so we suggest using the dioxus CLI tool to use subsecond. To install the Dioxus CLI, we recommend using cargo binstall: cargo binstall dioxus-cli The Dioxus CLI provides several tools for development. To run your application with Subsecond enabled, use dx serve - this takes the same arguments as cargo run but will automatically hot-reload your application when changes are detected. As of Dioxus 0.7, “–hotpatch” is required to use hotpatching while Subsecond is still experimental. §How it works Subsecond works by detouring function calls through a jump table. This jump table contains the latest version of the program’s function pointers, and when a function is called, Subsecond will look up the function in the jump table and call that instead. Unlike libraries like detour, Subsecond does not modify your process memory. Patching pointers is wildly unsafe and can lead to crashes and undefined behavior. Instead, an external tool compiles only the parts of your project that changed, links them tog...

First seen: 2025-06-24 21:13

Last seen: 2025-06-25 06:17