summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md31
-rw-r--r--src/trace/store.zig10
2 files changed, 28 insertions, 13 deletions
diff --git a/README.md b/README.md
index 64a11be..ce44bf4 100644
--- a/README.md
+++ b/README.md
@@ -50,7 +50,7 @@ is another, with the recorder at its far end.
An xitdb file, kept small. A **moment** stores only its events, encoded
compactly (registers as the ones that changed since the thread's last). The
-program's **state** is stored at a keyframe every 256 moments, each sharing
+program's **state** is stored at a keyframe every 4096 moments, each sharing
what did not change with the one before; the state at any moment is the
keyframe before it with the moments since replayed over it. `Trace.moment(i)`
is any of them, in any order: time travel is an index.
@@ -78,19 +78,32 @@ What a moment costs (`zig build bench-store`; release, this machine):
| each moment | bytes | ns |
| --- | --- | --- |
-| a mark | 29 | 560 |
-| a step with registers | 57 | 1100 |
-| ... and a word pushed on the stack | 75 | 960 |
-| a word written somewhere in 1 MiB of heap | 717 | 14700 |
-| 4 KiB written again, unchanged | 376 | 24000 |
-| 4 KiB of new bytes | 12078 | 584000 |
+| a mark | 24 | 290 |
+| a step with registers | 51 | 750 |
+| ... and a word pushed on the stack | 65 | 450 |
+| a word written somewhere in 1 MiB of heap | 320 | 9500 |
+| 4 KiB written again, unchanged | 370 | 22000 |
+| 4 KiB of new bytes | 12078 | 545000 |
An instruction-level recording of `fib(12)` under ptrace, 142 000 moments
-with registers and the stack, is 8 MB at 197 000 moments a second; reading
-it back is 178 000 moments a second in order, a millisecond to any one.
+with registers and the stack, is 8 MB at 197 000 moments a second. Reading
+is 6 µs a moment in order and a millisecond to any moment (three at worst).
Scattered writes and new bulk data are what cost: each chunk of 64 bytes
that changed is written at the next keyframe with its path in the tree.
+A larger program, to scale by: Lua 5.4 compiled by `ztrace cc` with
+everything instrumented (lines, calls, variables, stores, in all of its
+26 000 lines) and run on a ten-line script that takes it a millisecond.
+
+| what is instrumented | moments | events | recording | run |
+| --- | --- | --- | --- | --- |
+| everything | 3 248 000 | 7 353 000 | 156 MB | 1.7 s |
+| `--only luaV_execute` (the interpreter's loop) | 2 176 000 | 4 640 000 | 93 MB | 1.0 s |
+| `--instr calls` | 189 000 | 191 000 | 7 MB | 0.06 s |
+
+A moment a C line of an interpreter is a great many moments: choose what
+is instrumented (`--only`, `--mem`, `--instr`) before choosing to wait.
+
## Together
The backends are not modes to choose between: they feed one sink. A
diff --git a/src/trace/store.zig b/src/trace/store.zig
index 8d01570..c8c32e7 100644
--- a/src/trace/store.zig
+++ b/src/trace/store.zig
@@ -3,7 +3,7 @@
//!
//! root = map {
//! moments list of bytes: a moment's events, encoded (`Codec`)
-//! keys list of keyframe, one a batch of moments
+//! keys list of keyframe, one a batch of moments (4096)
//! }
//! keyframe = map {
//! moment the last moment it holds
@@ -339,9 +339,11 @@ pub const Recorder = struct {
cut: u64 = Kind.step.bit() | Kind.breakpoint.bit() | Kind.syscall_exit.bit() | Kind.signal.bit() | Kind.exit.bit() | Kind.line.bit() | Kind.mark.bit(),
/// ... or when its events pass this many bytes.
max_delta: usize = 1 << 20,
- /// Moments a keyframe, at most: what a reader replays to reach one. A
- /// crash loses the batch being gathered.
- batch: usize = 256,
+ /// Moments a keyframe, at most: what a reader replays to reach one (a
+ /// millisecond, measured), and what a crash loses. Fewer would be seeked
+ /// to faster and cost more: at 256 the keyframes were half of a
+ /// recording of Lua.
+ batch: usize = 4096,
/// The file may grow this large; past it `emit` is `error.RecordingFull`.
/// A recording is meant to be megabytes: reaching this means too much is
/// being recorded (every instruction of a long run, whole buffers).