Replay Composition
Interleaved Owner Summary
Preserve Order
An interleaved replay has one global order while each event still belongs to an owner. This program summarizes the ordered prefix.
Program
Play the program to choose a maximum step and watch owner totals accumulate in order.
interleaved_owner_summary_rust.rs
Replay: real traced execution (multi-file project)
fn main() {
let max_step: usize = 3;
let owners = ["main", "worker", "main", "worker"];
let deltas = [1, 2, 3, 4];
let mut main_total = 0;
let mut worker_total = 0;
for i in 0..max_step {
if owners[i] == "main" {
main_total += deltas[i];
} else {
worker_total += deltas[i];
}
}
println!("{main_total}:{worker_total}");
}
fn main() {
let max_step: usize = 2;
let owners = ["main", "worker", "main", "worker"];
let deltas = [1, 2, 3, 4];
let mut main_total = 0;
let mut worker_total = 0;
for i in 0..max_step {
if owners[i] == "main" {
main_total += deltas[i];
} else {
worker_total += deltas[i];
}
}
println!("{main_total}:{worker_total}");
}
fn main() {
let max_step: usize = 4;
let owners = ["main", "worker", "main", "worker"];
let deltas = [1, 2, 3, 4];
let mut main_total = 0;
let mut worker_total = 0;
for i in 0..max_step {
if owners[i] == "main" {
main_total += deltas[i];
} else {
worker_total += deltas[i];
}
}
println!("{main_total}:{worker_total}");
}
max_step ← 3, owners ← ["main", "worker", "main", "worker"], deltas ← [1, 2, 3, 4]
1fn main() {2 let max_ste→ 3p: usize = 3; //@max_step=2, 3, 43 let owner→ ["main", "worker", "main", "worker"]s = ["main", "worker", "main", "worker"];4 let delta→ [1, 2, 3, 4]s = [1, 2, 3, 4];5 let mut main_tota→ 0l = 0;6 let mut worker_tota→ 0l = 0;7 for i in 0..max_step {for i in 0..max_step
pass 1 of 36let mut worker_total = 0;7for 0i in 0..max_ste3p {8 if owners[i] == "main" {All 3 passes — pass 1 is the card above pass iowners[i]deltas[i]main_totalworker_total1 0 "main" 1 0 → 1 — 2 1 — 2 — 0 → 2 3 2 "main" 3 1 → 4 — main_total ← 1
pass 1 of 27for i in 0..max_step {8 if owners[i"main"] == "main" {9 main_tota→ 1l += deltas[i1];10 } else {worker_total ← 2
9 main_total += deltas[i];10} else {11 worker_tota→ 2l += deltas[i2];12}main_total ← 4
pass 2 of 27for i in 0..max_step {8 if owners[i"main"] == "main" {9 main_tota→ 4l += deltas[i3];10 } else {println!("{main_total}:{worker_total}");
13 }14 println!("{main_total}:{worker_total}");15}output4:2
max_step ← 2, owners ← ["main", "worker", "main", "worker"], deltas ← [1, 2, 3, 4]
1fn main() {2 let max_ste→ 2p: usize = 2;3 let owner→ ["main", "worker", "main", "worker"]s = ["main", "worker", "main", "worker"];4 let delta→ [1, 2, 3, 4]s = [1, 2, 3, 4];5 let mut main_tota→ 0l = 0;6 let mut worker_tota→ 0l = 0;7 for i in 0..max_step {for i in 0..max_step
pass 1 of 26let mut worker_total = 0;7for 0i in 0..max_ste2p {8 if owners[i] == "main" {main_total ← 1
7for i in 0..max_step {8 if owners[i"main"] == "main" {9 main_tota→ 1l += deltas[i1];10 } else {for i in 0..max_step
pass 2 of 26let mut worker_total = 0;7for 1i in 0..max_ste2p {8 if owners[i] == "main" {worker_total ← 2
9 main_total += deltas[i];10} else {11 worker_tota→ 2l += deltas[i2];12}println!("{main_total}:{worker_total}");
13 }14 println!("{main_total}:{worker_total}");15}output1:2
max_step ← 4, owners ← ["main", "worker", "main", "worker"], deltas ← [1, 2, 3, 4]
1fn main() {2 let max_ste→ 4p: usize = 4;3 let owner→ ["main", "worker", "main", "worker"]s = ["main", "worker", "main", "worker"];4 let delta→ [1, 2, 3, 4]s = [1, 2, 3, 4];5 let mut main_tota→ 0l = 0;6 let mut worker_tota→ 0l = 0;7 for i in 0..max_step {for i in 0..max_step
pass 1 of 46let mut worker_total = 0;7for 0i in 0..max_ste4p {8 if owners[i] == "main" {All 4 passes — pass 1 is the card above pass iowners[i]deltas[i]main_totalworker_total1 0 "main" 1 0 → 1 — 2 1 — 2 — 0 → 2 3 2 "main" 3 1 → 4 — 4 3 — 4 — 2 → 6 main_total ← 1
pass 1 of 27for i in 0..max_step {8 if owners[i"main"] == "main" {9 main_tota→ 1l += deltas[i1];10 } else {worker_total ← 2
pass 1 of 29 main_total += deltas[i];10} else {11 worker_tota→ 2l += deltas[i2];12}main_total ← 4
pass 2 of 27for i in 0..max_step {8 if owners[i"main"] == "main" {9 main_tota→ 4l += deltas[i3];10 } else {worker_total ← 6
pass 2 of 29 main_total += deltas[i];10} else {11 worker_tota→ 6l += deltas[i4];12}println!("{main_total}:{worker_total}");
13 }14 println!("{main_total}:{worker_total}");15}output4:6
global order
`max_step` selects a prefix of the ordered event list.
owner state
Each event updates the total for its owner.
interleaving
The loop alternates owners without using real threads.