Repository navigation
Virtual FileSystem
github-actions[bot] edited this page Dec 2, 2026
·
1 revision
Every SimHost owns a virtual in-memory filesystem (host.FileSystem) with explicit fsync durability semantics and simulated disk latency:
-
Flushed writes (
flush: trueorFlushAsync/FlushAllAsync) persist acrosshost.Crash()andhost.Restart(). -
Buffered writes (
flush: false) are visible to reads while the host is running, but are discarded onhost.Crash()(rolling back to the last flushed state). -
Torn writes (
Config.TornWriteProbability) deterministically persist a partial prefix of unflushed bytes on crash, allowing you to test Write-Ahead Log (WAL) framing, checksums, and recovery logic.
var host = sim.AddHost("storage");
host.FileSystem.Config.TornWriteProbability = 0.5;
await host.FileSystem.WriteAllTextAsync("state.dat", "committed", flush: true);
await host.FileSystem.WriteAllTextAsync("wal.log", "unflushed-tail", flush: false);
host.Crash();
// "state.dat" is intact; "wal.log" was dropped or torn deterministically based on the seed.See samples/Faultline.Samples.WriteAheadLog and samples/Faultline.Samples.LeaderElection for full end-to-end examples.