---
# System prepended metadata

title: 'Road trip on the coastline of lib_context replay :beach_with_umbrella:'

---

# Road trip on the coastline of lib_context replay :beach_with_umbrella:

# On the way to compiling `replay.exe` :sunny:


A combination of:
- https://tezos.gitlab.io/introduction/howtoget.html#setting-up-the-development-environment-from-scratch
- https://github.com/tarides/irmin-scratch/blob/main/scripts/benchmarking/run.py
- https://github.com/Ngoguey42/tezos/tree/replay_oct22


The benchmarking code is scattered between these directories: 
- `tezos/src/bin_context`
- `tezos/src/lib_context/recording` 
- `tezos/src/lib_context/replay`

Here is a recent full diff of the benchmarking code, 10k lines of code: https://github.com/Ngoguey42/tezos/compare/102881e81c9f9d0de159d6aa8f2c70e30bec466d..replay_oct22

There's a readme: https://github.com/Ngoguey42/tezos/blob/ba388aa70812eb94e0194ee1a5ea8c66b25d1295/src/bin_context/README.md

Running the 3 benchmarks with the 2 branches would take 17.8 hours.

Running the 2 short benchmarks with the 2 branches would take 100 minutes.

# Exploring the available actions traces and startup stores :mdr:

Files are on comanche at `/bench/ngoguey/ro/hangzu/`. See also the `README.md`

|                                                                    | comanche (/bench/ngoguey/ro/hangzu/)|
|--------------------------------------------------------------------|-------------------------------------|
| Store after the end of bootstrapping                               | store_post_node_run/                |
| At the beginning of H. Irmin 2.10                                  | store_imported_210/                 |
| At the beginning of H. Irmin 3.0                                   | store_imported_300/                 |
| At the beginning of H. Irmin 3.3                                   | store_imported_330/                 |
| Before the end of cycle 435. Contains 7 cycles. Irmin 3.3          | store_before-gc_330/                |
| Before the end of cycle 435. Contains 6 cycles. Irmin 3.4          | TODO                                |
| Trace from the beginning of H                                      | replay_trace.repr                   |
| Trace from the end of cycle 435                                    | replay_trace_gc.repr                |
| Before the end of cycle 435. Contains 7 cycles. Irmin 3.5 (chunks) | todo                                |
| Before the end of cycle 435. Contains 6 cycles. Irmin 3.5 (chunks) | todo                                |

# Where to go

### Generate `store_after-gc_340/` for `hangzhou-1cycle-0gc`

- Make an irmin branch on top of tag 3.4 that implements the new stats and that builds with the benchmark
- Hack the benchmark code not replay and just run a blocking GC
- Launch this on `store_before-gc_330/`

### Generate `store_before-gc_350/` for `hangzhou-few_blocks-1gc`

- Update the benchmark code to be able to generate chunks during a replay
- Update the bencmark CLI to be able to configurxe the split rate
- Launch a replay from `store_imported_330`, creating chunks every ???, stopping before replaying before block `1_982_464 (CoUsXcYJyYcYEA9UndQcoajBdLm6YwBzX8uPo6CsJ1sDMniZsWc3)`

### Generate `store_after-gc_350/` for `hangzhou-1cycle-0gc`

Same process as `store_after-gc_340` above but using `store_before-gc_350/`


# How to `Hack the benchmark code not replay and just run a blocking GC`

In `src/lib_context/replay/trace_replay.ml` insert this: `Context.gc rs.index target; <abort the program>;`. `target` is the hash of the target. `rs.index` is the outcome of `Context.init`, `exec_init` creates it.

# How to `Update the benchmark code to be able to generate chunks during a replay`

First get the version of lib_context that implements the split (kevin has this), and extract that feature (or cherry-pick) to the benchmarking branch.

Update replay config with this:
```split_when : [`Never | `Every of int];```

Update CLI so that the following is possible: `--split-when every-8191`

Update replay code in `exec_commit` to run a split just after the `Context.commit` and just before the `Context.gc`.

<!-- The end -->