Skip to content
glep

glep / Reference

Benchmarks

Measured glep, ripgrep and fd timings on the Linux kernel 6.12 tree, the setup behind them, later 2.0.0 measurements, and how to run the scripts.

On this page
  1. First principles
  2. Setup
  3. Results
  4. After the performance rewrite
  5. Later 2.0.0 measurements
  6. Earlier numbers (0.3.0 README)
  7. Reading the numbers
  8. Run it yourself

These are the numbers published in the glep README and changelog. They were measured on one machine, often with other work running. Your numbers will depend on the tree, the disk and the operating system.

First principles

A glep query costs four things: the freshness sweep (one metadata read per file), planning, searching the candidate files, and printing. A ripgrep query costs a walk plus reading every file. So:

  • glep’s gain grows with the share of files the index rules out. A rare pattern rules out almost everything; a very common one rules out little.
  • The sweep is a fixed cost per query that grows with file count. --ttl removes it, which is why the --ttl column is so much faster.
  • A pattern no trigram can narrow searches every file, so it runs at ripgrep’s speed at best.
  • The index build is a one-time cost. glep pays off only when the same tree is searched again.

Every row below follows from these four points.

Setup

From the README:

  • Corpus: Linux kernel 6.12 source tree (a tarball extract, not a git checkout): 86,604 files, 86,218 of them searched, 1.6 GB.
  • Machine: Apple M3 Pro, macOS.
  • Tools: glep 0.3.1 (the release before the 2.0.0 performance rewrite described below), rg 15.0 and fd 10.4 at their default parallelism.
  • Method: hyperfine means of 5 to 10 runs after warmup, warm filesystem cache, other work running on the machine.

glep’s numbers did not move between sessions. ripgrep’s full scan did, from 1.3 s on its best run to 3.5 s under load. So the ripgrep column shows the observed spread, and every ratio is a lower bound, rounded down: indexed rows are compared with ripgrep’s fastest full scan (1.3 s), full-scan rows with that row’s own fastest ripgrep run.

Results

Each row lists glep, glep with --ttl 60, ripgrep, and the lower-bound speedup (glep, then glep with --ttl).

  • Rare pattern (46 lines in 11 files): 172 ms, 21 ms, rg 1.3 to 3.5 s. At least 7x and 61x.
  • Rare pattern with -l, -i, -U or -C 2: 171 to 177 ms, 20 to 27 ms, rg 2.9 to 3.7 s under load. At least 7x and 48x.
  • Common pattern (EXPORT_SYMBOL_GPL, 20k lines in 3.5k files): 234 ms, 81 ms, rg 2.6 to 3.7 s under load. At least 5x and 16x.
  • Very common pattern (static, 831k lines in 40k files): 1.69 s, 1.37 s, rg 2.5 to 3.4 s. At least 1.5x and 1.8x.
  • Single character q (no trigram, full scan): 3.36 s, 3.13 s, rg 2.8 to 3.3 s. 0.8x and 0.8x.
  • List all .c files (--files, 34,657 files): 195 ms, 45 ms, rg --files 71 ms and fd 74 ms. 0.3x and 1.5x.

Index build (one-time): 28 s. Index size: 154 MB, about 10% of the corpus.

On a small 86-file Python repository both tools answer in single-digit milliseconds: glep 4.5 ms against rg 7.0 ms, and --files 3.4 ms against rg --files 4.9 ms and fd 7.5 ms. The index pays off at scale, not on small trees.

After the performance rewrite

The README also reports a performance branch measured in the same sessions on the same corpus: a worker-pool search with one reusable searcher per thread, zero-copy memory-mapped verification, a parallel freshness diff, and the listing cache keyed on directory modification times (mtimes). That work shipped in 2.0.0. When it was measured, the branch memory-mapped every file it searched; 2.0.0 reads files up to 1 MiB into a reused buffer instead. Its numbers, glep then glep with --ttl:

  • Rare pattern: 97 ms, 24 ms.
  • Common pattern: 152 ms, 76 ms.
  • static: 1.50 s, 1.28 s.
  • --files: 61 ms with or without --ttl, ahead of rg --files (71 ms) and fd (74 ms).

Later 2.0.0 measurements

The changelog records before-and-after numbers for later changes in 2.0.0, each from its own hyperfine session on the kernel tree. They are not directly comparable with the tables above.

  • Worker count on macOS. Defaulting to the performance-core count took glep q from 2.44 s to 1.35 s, glep -c ab from 2.70 s to 1.15 s, and glep static from 1.24 s to 0.78 s, against ripgrep’s 2.36 s, 2.40 s and 2.31 s on the same busy machine.
  • First query on an unindexed tree. With the background build, the first query went from 26.4 s to 2.6 s for PCI_EXP_LNKCTL2_TLS and from 25.5 s to 2.6 s for static, against ripgrep’s 1.5 s and 1.8 s. The build then took 22 to 24 s in the background, and the next query took 150 ms against ripgrep’s 1.57 s.
  • Cheaper listing-cache walk. Root-wide listings got about twice as fast: --files from 64.7 ms to 31.7 ms mean, and --files '**/*.c' from 60.8 ms to 30.8 ms, against ripgrep’s 72.1 ms and 70.3 ms.
  • Scoped listings. --files '**' drivers/net went from 22.4 ms to 7.9 ms mean, against ripgrep’s 10.1 ms.

Earlier numbers (0.3.0 README)

The README for 0.3.0 published a smaller table, measured on a Linux kernel 6.12 checkout of 86,605 files (about 1.5 GB) with hyperfine medians: rare pattern 173 ms (21 ms with --ttl 5) against ripgrep’s 1.42 s; common pattern 298 ms (90 ms) against 1.54 s; listing all .c files 242 ms (44 ms) against fd’s 92 ms; index build 24 s.

Reading the numbers

  • Default glep pays the self-healing freshness sweep on every query: on macOS one bulk attribute call per directory, elsewhere a metadata read per file. --ttl skips it within a read burst, which is where the 20 to 81 ms figures come from.
  • Patterns shorter than three bytes, or otherwise trigram-free like .*, cannot be narrowed by any trigram index, so glep falls back to a full parallel scan and runs at ripgrep’s speed (the q row).
  • In the README’s table, --files beats rg --files and fd only inside a --ttl window. In 2.0.0 the listing cache removes that gap on macOS.
  • The index build costs more than a single ripgrep search. glep pays off only when the same tree is searched repeatedly.
  • The parity harness pins byte equality of the text output with ripgrep’s. Speed differs; bytes do not.

Run it yourself

The repository includes two scripts.

bench/bench.sh compares glep with ripgrep and fd on one pattern. It needs hyperfine and ripgrep on your PATH; fd is optional.

bench/bench.sh /path/to/big/repo 'some_pattern' ['*.rs']

The script:

  1. Runs glep index in the target directory.
  2. Times glep, glep --ttl 60 and rg -n --no-heading --color=never --no-require-git for the plain pattern and for -l, -i, -U and -C 2, with 2 warmup runs. These are the content rows of the README’s table.
  3. Times glep --files '**/GLOB', the same with --ttl 60, rg --no-require-git --files -g 'GLOB' and, if installed, fd --no-require-git -g 'GLOB'. The glob defaults to *.rs.

ripgrep runs at its default parallelism, without --sort path, which would make it single-threaded. --no-require-git makes ripgrep apply .gitignore the way glep does outside a git repository.

bench/compare.sh is the kernel-tree benchmark and differential harness:

GLEP=/path/to/glep bench/compare.sh /path/to/corpus [out_dir]

It times a clean index build, checks that glep’s output equals rg --sort path byte for byte for each scenario and for two --files listings, records GLEP_TIMING stage timings, and runs hyperfine for glep, glep with --ttl 60, ripgrep, and ripgrep with --sort path. It needs hyperfine, fd and python3. Environment variables: RG (default rg), RUNS (hyperfine runs, default 7), SCEN_FILE (a file of scenarios, one name|arg;arg per line), and LABEL. The default scenarios assume a large C code base.