diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 55 |
1 files changed, 54 insertions, 1 deletions
@@ -67,6 +67,10 @@ is any of them, in any order: time travel is an index. | `string(id)` | `string` | | `events()` | everything, as it came | +From a debugger's recording, `zt.telescope`: `instruction(m, addr, buf)` is an instruction's text, its source `line`, and for a direct call its callee's `params` (DWARF's); `frames(m, regs, out)` is the call chain with each frame's extent on the stack, `low` to `high` (a `stack()` frame's is up to `sp + 8`). +With `--alloc`, every live allocation and the 16 bytes of allocator header before it are in `read` at each stop (its first 4 KiB; what changed, a stop at a time; 256 KiB of them at most, lowest addresses first: `Debugger.allocation_watch`). +Recorded `--by insn`, the instructions that ran between two moments are the `rip` of each moment between them; `--by line` does not keep them. + The recorder ends a moment at the kinds in `Recorder.cut` (by default a step, a breakpoint, a syscall's exit, a signal, a source line, a mark). Of a memory write it keeps only the bytes that differ from what it already @@ -139,7 +143,56 @@ compiler thread cloned from inside the agent's syscall handler could not read its own code space, and d8 died. The handlers now act with the thread's keys and float modes (`src/agent/signal.zig`). `--alloc` sees nothing in d8, which binds its own `malloc`: hook it instead. C++ names -are shown and matched as the linker has them, mangled. +are shown and matched as the source has them, without their parameters +(`-b v8::internal::Heap::CollectGarbage`; the mangled name works too): +the command links zig's libc++ for its demangler. + +## SQLite + +Between Lua and V8 on the ladder: SQLite 3.50.4's amalgamation (one C +file of 263 000 lines), its shell built by clang `-O2 -g +-fno-omit-frame-pointer`, on a file database: two tables and an index, +5 100 rows inserted in a transaction, a count, a join with an aggregate, +a lookup through the index. Alone it takes 5.5 ms, 51 million +instructions and 321 syscalls. `sh bench/sqlite.sh PREFIX SRC` builds the +shells and makes each row (a release ztrace installed at PREFIX; time is +the tracer's own measure of the program's run, the best of three; seek is +`ztrace show` of the middle moment: the file opened, the moment replayed +from its keyframe, printed). + +| backend | moments | events | recording | a moment | time | × alone | moments/s | events/s | seek | +| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | +| `record --by syscall` | 322 | 3 593 | 0.3 MB | 830 B | 21 ms | 3.9 | 15 100 | 169 000 | 1.4 ms | +| `record --by line`, its first million lines | 1 000 000 | 2 843 000 | 108 MB | 107 B | 31 s | | 32 000 | 91 000 | 6.8 ms | +| `record --by line --max-size 2G`, all of it | 16 890 000 | 46 462 000 | 1.7 GB | 100 B | 504 s | 92 000 | 33 500 | 92 000 | 13 ms | +| `record --by break -b sqlite3BtreeInsert` | 15 539 | 82 401 | 3.5 MB | 223 B | 440 ms | 80 | 35 300 | 187 000 | 4.3 ms | +| `run --preload ... --alloc` | 1 | 1 353 | 36 KB | | 6.4 ms | 1.2 | | 211 000 | 1.1 ms | +| `run --preload ... --syscalls` | 282 | 601 | 45 KB | 161 B | 7.0 ms | 1.3 | 40 300 | 86 000 | 3.9 ms | +| `run --preload ... --hook sqlite3BtreeInsert` | 30 434 | 30 473 | 2.7 MB | 88 B | 25 ms | 4.5 | 1 240 000 | 1 240 000 | 3.0 ms | +| `perf --faults --syscalls` | 321 | 889 | 0.1 MB | 160 B | 19 ms | 3.5 | 16 800 | 46 500 | 1.3 ms | +| `perf --break sqlite3BtreeInsert` | 2 | 15 258 | 2.0 MB | | 25 ms | 4.6 | | 603 000 | 2.5 ms | +| `cc` (everything), `run` | 21 789 000 | 40 825 000 | 1.06 GB | 48 B | 16.3 s | 2 960 | 1 340 000 | 2 511 000 | 45 ms | +| `cc --only sqlite3VdbeExec`, `run` | 5 873 000 | 9 401 000 | 221 MB | 37 B | 2.5 s | 457 | 2 335 000 | 3 737 000 | 6.5 ms | +| `cc --instr calls`, `run` | 2 925 000 | 2 930 000 | 98 MB | 33 B | 1.05 s | 191 | 2 777 000 | 2 782 000 | 2.0 ms | +| `cc --instr calls`, `record --by break -b sqlite3BtreeInsert --alloc --preload ...` | 15 626 | 3 167 770 | 53 MB | 3 379 B | 1.16 s | 211 | 13 400 | 2 726 000 | 4.8 ms | + +Built by `ztrace cc` and run with nobody listening, the shell takes 108 ms +with everything instrumented, 23 with `--only sqlite3VdbeExec`, 11 with +`--instr calls`. `ztrace dbg` with `b sqlite3VdbeExec`, `r`, `bt` gives 19 +frames, from the interpreter through `sqlite3InitOne`, the parser's +`yy_reduce` and `sqlite3_prepare_v2` to the shell's `process_input` and +`_start`; `b sqlite3.c:80895` is `sqlite3BtreeInsert`. Under ptrace with +the allocations told (the last row), each stop compares the 155 live +allocations, 78 KB of them with their headers: 3 379 bytes a moment and +1.16 s, against 3 098 and 0.63 s before allocations were read. + +SQLite found two things. A file's name in DWARF may be absolute (the +amalgamation compiled by its full path), and the debugger joined it to the +compilation's directory anyway: every `line` named a file that was not +there. And `ztrace run` noticed a target's exit only when its idle wait of +10 ms ran out, so a 5 ms program took 15; it waits a millisecond now. +Recorded a line a moment, the whole run is past the gigabyte a recording +is allowed by default. ## Together |
