This check measures one ripgrep search for a fixed string across a freshly
created checkout of PostHog shared in from your machine. The checkout has about
47 000 files and is 589 MB. Nothing reads the files through the container
before the search.
The result is the duration of the single search command in milliseconds,
measured inside the container. ripgrep chooses its own thread count. The
parallelism your engine gives a container is part of what you measure.
For how durations are taken and how to repeat a check, see Performance checks .
Get the source
$ mkdir -p ~/perfcheck/code-search && cd ~/perfcheck/code-search
$ git init --bare -q posthog-mirror.git
$ git -C posthog-mirror.git remote add origin https://github.com/PostHog/posthog.git
$ git -C posthog-mirror.git fetch -q --depth=1 origin 4fa8e10ae2e988fd64ce93c8408856100af16c4f
$ git -C posthog-mirror.git update-ref refs/heads/pinned FETCH_HEAD
$ git -C posthog-mirror.git rev-parse refs/heads/pinned
4fa8e10ae2e988fd64ce93c8408856100af16c4f
Run the check
Create a fresh checkout. This step isn't timed.
$ rm -rf fixture && mkdir fixture $ git clone -q --no-local --no-checkout posthog-mirror.git fixture/repo $ git -C fixture/repo checkout -q --detach 4fa8e10ae2e988fd64ce93c8408856100af16c4fStart a container with the checkout shared in, and install
ripgrep. Neither command reads the checkout.$ docker run -d --rm --name perfcheck-code-search \ -v "$PWD/fixture/repo:/work" -w /work \ alpine:3.24.1 sleep infinity $ docker exec perfcheck-code-search apk add --no-cache ripgrep=~15.1.0 coreutilsConfirm the version. Different
ripgrepreleases search at different speeds.$ docker exec perfcheck-code-search sh -c 'rg --version | head -1' ripgrep 15.1.0Run the timed command:
$ docker exec perfcheck-code-search sh -c ' set -e start=$(date +%s%3N) rg --no-config --hidden --glob "!.git/**" --fixed-strings posthog . >/dev/null end=$(date +%s%3N) printf "search_ms=%s\n" "$((end - start))" 'The value of
search_msis the result.Check that the run is valid. Run the same search again, without timing it, and compare the output with the expected values:
$ docker exec perfcheck-code-search sh -c ' rg --no-config --hidden --glob "!.git/**" --fixed-strings posthog . > /tmp/search.out printf "lines=%s\n" "$(wc -l < /tmp/search.out | tr -d " ")" printf "digest=%s\n" "$(sed "s/\r$//" /tmp/search.out | LC_ALL=C sort | sha256sum | cut -d " " -f 1)" 'Expected output:
lines=177556 digest=7b8e6be6abc6421718afda2e33a16b59b137f300895b75a2cea42ce98a9de996Any other output means you searched a different set of files or used a different
ripgrepversion. The duration isn't comparable.Clean up:
$ docker rm -f perfcheck-code-search $ rm -rf fixture