Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Measuring shim overhead

drawbar bench times git run directly with the real git against git run through the ~/.local/bin/git shim, and reports what the shim adds:

$ drawbar bench --repo ~/src/widgets
drawbar bench 0.1.0

real git  /home/acme/.local/opt/git-2.56.1/bin/git (git 2.56.1)
shim      /home/acme/.local/bin/git
repo      /home/acme/src/widgets
runs      50 of each command each way, after 5 warmup

git --version
  direct    median  0.852 ms  p95  1.143 ms
  shim      median  1.214 ms  p95  1.581 ms
  overhead  median +0.362 ms  p95 +0.438 ms

git status --porcelain
  direct    median 41.302 ms  p95 44.826 ms
  shim      median 41.718 ms  p95 45.407 ms
  overhead  median +0.416 ms  p95 +0.581 ms

Bench runs git --version and git status --porcelain, each through the real git the shim resolves and through the shim, and reports the median and the p95 of each, then the overhead: the shim’s median minus the direct median, and the same for the p95. Both run in the repository with the same environment, so the shim run includes everything the shim does there: resolving the real git, reading the config, the auto-GC guard, and any core.fsmonitor flags. When the shim turns fsmonitor on for a large repository, its git status can beat the direct run, and the overhead is negative.

Each round runs every command both ways and alternates which runs first, so a change in machine load falls on both. Warmup rounds run first and are not counted.

OptionDefaultMeaning
--repo <path>the current directoryWhere git status runs. The report names the repository’s top level.
--iterations <n>50Counted runs of each command each way, from 1 to 10000.
--warmup <n>5Uncounted runs before them, from 0 to 10000.
--jsonPrint one JSON object instead of text.

drawbar bench --json prints the real_git path and version, the shim, the repo, iterations, warmup, and one entry per command in commands, each with direct, shim and overhead times as median_us and p95_us in whole microseconds. The text report shows the same values in milliseconds. Bench exits 0 once the report is printed, 1 when the shim is not installed, no real git resolves, the path is not in a git repository, or a timed git command fails, and 2 for a bad argument.