rust-lang / rfcs

RFCs for changes to Rust
https://rust-lang.github.io/rfcs/
Apache License 2.0
5.78k stars 1.55k forks source link

Deterministic parallel execution of native threads #1090

Open kmcallister opened 9 years ago

kmcallister commented 9 years ago

Bergan, Anderson, Devietti, Ceze & Grossman. (2010). CoreDet: a compiler and runtime system for deterministic multithreaded execution. ACM SIGARCH Computer Architecture News 38(1), pp. 53-64.

The applications include:

The system described in the paper uses alternating stages of parallel and serial execution, each bounded in time. In the simplest execution model, inter-thread communication blocks until serial mode. They also describe how to optimize this using approaches similar to cache coherence.

Their implementation uses an LLVM pass to instrument each access to possibly-shared memory. In Rust it should suffice to instrument std::sync::atomic or the equivalent LLVM intrinsics. From §7.3:

for data race free programs, deterministic synchronization is sufficient for full determinism

The LLVM pass injects other code to handle calls to external libraries (which may have uninstrumented data races), and to provide deterministic, bounded time quanta during execution. rr uses hardware performance counters for the latter purpose, which would be an interesting variation to explore.

naturallymitchell commented 4 years ago

See https://github.com/rust-lang/rfcs/issues/819 for Rust-native tools to handle this.