An interleaved replay keeps one global order while each event still belongs to one owner. This script summarizes that shape with vectors.

Program

Play the script to choose how many ordered events to include and watch owner totals accumulate.

max_step
interleaved_step_summary.R
Replay: real traced execution (multi-file project)
max_step <- 3
owners <- c("main", "worker", "main", "worker")
deltas <- c(1, 2, 3, 4)
main_total <- 0
worker_total <- 0
for (i in seq_len(max_step)) {
    if (owners[i] == "main") {
        main_total <- main_total + deltas[i]
    } else {
        worker_total <- worker_total + deltas[i]
    }
}
label <- paste(main_total, worker_total, sep = ":")
cat(label, "\n", sep = "")
max_step <- 2
owners <- c("main", "worker", "main", "worker")
deltas <- c(1, 2, 3, 4)
main_total <- 0
worker_total <- 0
for (i in seq_len(max_step)) {
    if (owners[i] == "main") {
        main_total <- main_total + deltas[i]
    } else {
        worker_total <- worker_total + deltas[i]
    }
}
label <- paste(main_total, worker_total, sep = ":")
cat(label, "\n", sep = "")
max_step <- 4
owners <- c("main", "worker", "main", "worker")
deltas <- c(1, 2, 3, 4)
main_total <- 0
worker_total <- 0
for (i in seq_len(max_step)) {
    if (owners[i] == "main") {
        main_total <- main_total + deltas[i]
    } else {
        worker_total <- worker_total + deltas[i]
    }
}
label <- paste(main_total, worker_total, sep = ":")
cat(label, "\n", sep = "")
  1. max_step ← 3

    1max_step <- 32owners <- c("main", "worker", "main", "worker")
    values this step3max_step
  2. owners ← main, worker, main, worker

    1max_step <- 32owners <- c("main", "worker", "main", "worker")3deltas <- c(1, 2, 3, 4)
    values this stepmain, worker, main, workerowners
  3. deltas ← 1, 2, 3, 4

    2owners <- c("main", "worker", "main", "worker")3deltas <- c(1, 2, 3, 4)4main_total <- 0
    values this step1, 2, 3, 4deltas
  4. main_total ← 0

    3deltas <- c(1, 2, 3, 4)4main_total <- 05worker_total <- 0
    values this step0main_total
  5. worker_total ← 0

    4main_total <- 05worker_total <- 06for (i in seq_len(max_step)) {
    values this step0worker_total
  6. i ← 1

    5worker_total <- 06for (i in seq_len(max_step)) {7    if (owners[i] == "main") {
    values this step1i
  7. if (owners[i] == "main")

    6for (i in seq_len(max_step)) {7    if (owners[i] == "main") {8        main_total <- main_total + deltas[i]
    values this stepTRUEowners[1] == "main"
  8. main_total ← 1

    7if (owners[i] == "main") {8    main_total <- main_total + deltas[i]9} else {
    values this step0 1main_total1deltas[1]
  9. i ← 2

    5worker_total <- 06for (i in seq_len(max_step)) {7    if (owners[i] == "main") {
    values this step2i
  10. if (owners[i] == "main")

    6for (i in seq_len(max_step)) {7    if (owners[i] == "main") {8        main_total <- main_total + deltas[i]
    values this stepFALSEowners[2] == "main"
  11. worker_total ← 2

    9} else {10    worker_total <- worker_total + deltas[i]11}
    values this step0 2worker_total2deltas[2]
  12. i ← 3

    5worker_total <- 06for (i in seq_len(max_step)) {7    if (owners[i] == "main") {
    values this step3i
  13. if (owners[i] == "main")

    6for (i in seq_len(max_step)) {7    if (owners[i] == "main") {8        main_total <- main_total + deltas[i]
    values this stepTRUEowners[3] == "main"
  14. main_total ← 4

    7if (owners[i] == "main") {8    main_total <- main_total + deltas[i]9} else {
    values this step1 4main_total3deltas[3]
  15. label ← 4:2

    12}13label <- paste(main_total, worker_total, sep = ":")14cat(label, "\n", sep = "")
    values this step4:2label4main_total2worker_total
  16. cat(label, " ", sep = "")

    13label <- paste(main_total, worker_total, sep = ":")14cat(label, "\n", sep = "")
    output4:2
    values this step4:2label
  1. max_step ← 2

    1max_step <- 22owners <- c("main", "worker", "main", "worker")
    values this step2max_step
  2. owners ← main, worker, main, worker

    1max_step <- 22owners <- c("main", "worker", "main", "worker")3deltas <- c(1, 2, 3, 4)
    values this stepmain, worker, main, workerowners
  3. deltas ← 1, 2, 3, 4

    2owners <- c("main", "worker", "main", "worker")3deltas <- c(1, 2, 3, 4)4main_total <- 0
    values this step1, 2, 3, 4deltas
  4. main_total ← 0

    3deltas <- c(1, 2, 3, 4)4main_total <- 05worker_total <- 0
    values this step0main_total
  5. worker_total ← 0

    4main_total <- 05worker_total <- 06for (i in seq_len(max_step)) {
    values this step0worker_total
  6. i ← 1

    5worker_total <- 06for (i in seq_len(max_step)) {7    if (owners[i] == "main") {
    values this step1i
  7. if (owners[i] == "main")

    6for (i in seq_len(max_step)) {7    if (owners[i] == "main") {8        main_total <- main_total + deltas[i]
    values this stepTRUEowners[1] == "main"
  8. main_total ← 1

    7if (owners[i] == "main") {8    main_total <- main_total + deltas[i]9} else {
    values this step0 1main_total1deltas[1]
  9. i ← 2

    5worker_total <- 06for (i in seq_len(max_step)) {7    if (owners[i] == "main") {
    values this step2i
  10. if (owners[i] == "main")

    6for (i in seq_len(max_step)) {7    if (owners[i] == "main") {8        main_total <- main_total + deltas[i]
    values this stepFALSEowners[2] == "main"
  11. worker_total ← 2

    9} else {10    worker_total <- worker_total + deltas[i]11}
    values this step0 2worker_total2deltas[2]
  12. label ← 1:2

    12}13label <- paste(main_total, worker_total, sep = ":")14cat(label, "\n", sep = "")
    values this step1:2label1main_total2worker_total
  13. cat(label, " ", sep = "")

    13label <- paste(main_total, worker_total, sep = ":")14cat(label, "\n", sep = "")
    output1:2
    values this step1:2label
  1. max_step ← 4

    1max_step <- 42owners <- c("main", "worker", "main", "worker")
    values this step4max_step
  2. owners ← main, worker, main, worker

    1max_step <- 42owners <- c("main", "worker", "main", "worker")3deltas <- c(1, 2, 3, 4)
    values this stepmain, worker, main, workerowners
  3. deltas ← 1, 2, 3, 4

    2owners <- c("main", "worker", "main", "worker")3deltas <- c(1, 2, 3, 4)4main_total <- 0
    values this step1, 2, 3, 4deltas
  4. main_total ← 0

    3deltas <- c(1, 2, 3, 4)4main_total <- 05worker_total <- 0
    values this step0main_total
  5. worker_total ← 0

    4main_total <- 05worker_total <- 06for (i in seq_len(max_step)) {
    values this step0worker_total
  6. i ← 1

    5worker_total <- 06for (i in seq_len(max_step)) {7    if (owners[i] == "main") {
    values this step1i
  7. if (owners[i] == "main")

    6for (i in seq_len(max_step)) {7    if (owners[i] == "main") {8        main_total <- main_total + deltas[i]
    values this stepTRUEowners[1] == "main"
  8. main_total ← 1

    7if (owners[i] == "main") {8    main_total <- main_total + deltas[i]9} else {
    values this step0 1main_total1deltas[1]
  9. i ← 2

    5worker_total <- 06for (i in seq_len(max_step)) {7    if (owners[i] == "main") {
    values this step2i
  10. if (owners[i] == "main")

    6for (i in seq_len(max_step)) {7    if (owners[i] == "main") {8        main_total <- main_total + deltas[i]
    values this stepFALSEowners[2] == "main"
  11. worker_total ← 2

    9} else {10    worker_total <- worker_total + deltas[i]11}
    values this step0 2worker_total2deltas[2]
  12. i ← 3

    5worker_total <- 06for (i in seq_len(max_step)) {7    if (owners[i] == "main") {
    values this step3i
  13. if (owners[i] == "main")

    6for (i in seq_len(max_step)) {7    if (owners[i] == "main") {8        main_total <- main_total + deltas[i]
    values this stepTRUEowners[3] == "main"
  14. main_total ← 4

    7if (owners[i] == "main") {8    main_total <- main_total + deltas[i]9} else {
    values this step1 4main_total3deltas[3]
  15. i ← 4

    5worker_total <- 06for (i in seq_len(max_step)) {7    if (owners[i] == "main") {
    values this step4i
  16. if (owners[i] == "main")

    6for (i in seq_len(max_step)) {7    if (owners[i] == "main") {8        main_total <- main_total + deltas[i]
    values this stepFALSEowners[4] == "main"
  17. worker_total ← 6

    9} else {10    worker_total <- worker_total + deltas[i]11}
    values this step2 6worker_total4deltas[4]
  18. label ← 4:6

    12}13label <- paste(main_total, worker_total, sep = ":")14cat(label, "\n", sep = "")
    values this step4:6label4main_total6worker_total
  19. cat(label, " ", sep = "")

    13label <- paste(main_total, worker_total, sep = ":")14cat(label, "\n", sep = "")
    output4:6
    values this step4:6label
global order `max_step` selects a prefix of the global event order.
owner totals Each ordered event updates the total for its owner.
interleaving The loop alternates between owners while preserving one replay order.