How We Matched ripgrep in C# and Avalonia — 13 Fixes to Huge-File Search, From 205 s to 51.70 s on 50 GB

Dev Notes

UwView is a viewer for opening and searching huge logs and text files on Windows, macOS and Linux. The window is built with Avalonia UI and everything underneath is .NET 10 (C#). It also ships command-line tools that use the same search engine as the window: uvf in the free UwView, and uvp in the paid UwView Pro. I am the developer.

Question: Can an app written in C# (.NET) with Avalonia search a huge file about as fast as ripgrep, which is written in Rust?

Answer: Yes, it reached the same level. The 50 GB search went from 205 s to 51.70 s, level with ripgrep’s 54.94 s. What made the difference was not the language but how many times we read the same file, how we read it, and the fixed cost paid on every run. A Rust port of the same design ran at the same speed as the C# version.

This page regathers, for developers, the numbers from the 13-part “First Light” series (September 2026) and two articles written after it. Every number is a measurement from those articles, unchanged; nothing new was measured for this page. Most of them come from a single Mac. Where we still lose, we say so.

Note on file sizes: “50GB” here is 51,254,526,392 bytes (47.73 GiB), “3GB” is 3,032,812,644 bytes and “10GB” is 10,255,315,281 bytes. All of them are OpenStreetMap data expanded to XML.

We gave v1.6.6 the pet name “First Light”: it was the version where both the window and the commands could open and search a file by reading it only once, which made UwView feel complete for the first time.

The short answer: in 13 fixes we only touched how often we read, how we read, and the fixed cost. None of them made an algorithm smarter

  1. We started 3.7x behind. At v1.6.0 (September 15, 2026), a 50 GB search took 205 s with uvf and 56 s with ripgrep. Opening the same file on screen took 100.6 s.
  2. The fix was counting how many times we read the same file. Collecting line positions, searching, and re-reading the hit lines each read the file separately, two and a half passes in total. Folding them into one pass took us from 203 s to 50.82 s. After that we replaced mmap with pread for full reads and cut the fixed cost per run.
  3. We stopped at the raw speed of the external SSD. Reads went from 486 MB/s to 967 MB/s. That is the limit of the drive, so this direction has nothing left.
  4. It was not “Rust is faster”. A Rust port of the search ran at the same speed as the C# version (36.85 s vs 37.55 s), and the gap to ripgrep did not close.

1. Where we started and where we ended (50 GB, cold)

Mac (Apple M4, 10 cores, 32 GB of memory, external USB SSD), measured right after dropping the cache with sudo purge (cold). “Level” means a gap under 1.5x (section 3).

What we compared At the start (s) v1.6.6 “First Light” (s) Other tool (s) Result now
Search 50 GB once (uvf) 205 51.70 ripgrep 54.94 Level (1.06x faster than ripgrep)
Open 50 GB on screen 100.6 50.44 klogg 52.55 Level (1.04x faster than klogg)
Open, search and list hits on screen, end to end 189.5 53.7 klogg 108.14 2.01x faster than klogg
Search a gzip equivalent to 50 GB 35.65 17.20 gzip -dc \| rg 22.06 Level (1.28x faster than gzip -dc \| rg)
Effective read speed MB/s
At the start 486
v1.6.6 (3 GB / 10 GB / 50 GB) 967 / 966 / 969
Raw read speed of the external USB SSD 950–970

Getting the same number at three file sizes means we were no longer measuring our code; we were measuring the drive. Because we had measured that limit first, we knew this was where to stop.

The “at the start” column mixes v1.6.5 for the window and v1.6.0–v1.6.2 for the commands. It is not a list from a single version.

2. The thirteen fixes

Part What we changed Before → after
1 Measured where 205 s went. Collecting line positions (about 100 s), searching (about 82 s) and re-reading hit lines (about 20 s) each read the file separately (measurement only)
2 Folded the three into a single pass 50 GB: 203 s → 50.82 s
3 -i folds ASCII case on raw bytes instead of decoding to strings 3 GB second run: 2.72 s → 0.66 s (ripgrep 0.63 s, level)
4 Pull “required literals” out of a regex, conservatively, and narrow lines with them first 50 GB -E: 13.68 s → 7.75 s
5 The same command returned different counts each time (parallel workers stopped once one million hits were collected). Removed the default cap; a capped run now exits with code 2 Chose reproducibility over speed (50 GB: 1.24 s → 27.12 s; ripgrep 60.35 s)
6 Hand the command’s results to the window through one temp file, so the window does not read the file again 50 GB end to end: 50.76 s (klogg 108.14 s)
7 Losing only at 3 GB was a fixed cost. Turned off a tiered JIT setting and dropped an external command used for the license check (about 0.2 s per run) 3 GB second run, 7 searches: 11.46 s → 7.95 s. uvp went from ripgrep being 1.48x faster to uvp being 1.16x faster
8 Read gzip without external commands. On macOS, call the OS zlib directly and check CRC32 8 bytes at a time gzip equivalent to 50 GB: 35.65 s → 17.20 s
9 Decided what counts as a “difference” before measuring: under 1.5x for one item, under 1.3x for a total of 7 or more, is not a difference Lowering the bar from 2x to 1.5x flipped six of our verdicts against ripgrep
10 mmap for what the window shows, pread (4 MB at a time) for full reads Reads 551 → 966 MB/s; opening 50 GB 100.6 s → 50.44 s
11 Counted newlines faster (1.74 → 3.27 GB/s in memory) Reading from the disk, both ran at 968–969 MB/s; the clock did not move
12 Ran the same measurement procedure on Mac, Windows and Linux (virtual machine). Windows “cold” had not been cold, so we redid all of it Zero output mismatches against ripgrep and sed on all three
13 Series recap The table in section 1

Laid out like this, not a single part brought in a new algorithm. Every one of them either read fewer times, read differently, or cut what is paid on every run.

The newline counting that “did not move the clock” in part 11 paid off later. On a second run, with the file already in memory, nothing waits for the disk, so the time spent counting newlines shows up directly. Counting 16 bytes at a time took that from 0.15 s to 0.028 s on 3 GB, and the second search edged past ripgrep (3 GB: 0.29 s vs 0.31 s, v1.7.3.6.9).

3. What was specific to C# (.NET) and Avalonia

Less could be blamed on the language or the framework than I expected. Still, a few things were specific to .NET.

  • The tiered JIT setting (part 7): .NET first compiles quickly and later recompiles the hot paths. For a command that runs once and exits, that work is pure fixed cost, and it was why we lost only on small files like 3 GB. Turning off TieredCompilationQuickJitForLoops took the 3 GB second run of 7 searches from 11.46 s to 7.95 s. The same setting in the free uvf moved it only from 8.33 s to 8.23 s (1.2%), because uvf was bound by reads.
  • NativeAOT and regex: the uvf we ship is NativeAOT (compiled ahead of time). In that form the .NET regex engine runs interpreted, so heavy patterns that must run on every line get slow. Those patterns are handed to the window’s main executable in the same folder, where the JIT works.
  • Case-insensitive matching (part 3): across the whole BMP, the only non-ASCII character that .NET’s IgnoreCase | CultureInvariant matches to an ASCII letter is U+212A, the Kelvin sign. Handle that one character separately and folding case on raw bytes gives the same answers.
  • The window (Avalonia) side (parts 6 and 10): the window reads only what is on screen as you scroll, which suits mmap, but reading a file from start to end (collecting line positions, searching) is faster with pread; sequential mmap reads reached only 57% of pread. Splitting display and full reads halved the time to open 50 GB. Results found by the command are passed to the window through one temp file so the window does not read the file a second time.

Did a Rust rewrite catch ripgrep?

To check whether “Rust is faster”, I ported the search part of uvf to Rust. After confirming that its output did not differ from uvf by a single byte, I measured it on the Linux kernel sources (86,000 files) with 5 searches (cold + hot, median of 3 runs, October 4, 2026).

ripgrep (s) uvf, C# (s) Rust port, leaning on the regex crate (s) Rust port, line-for-line (s)
30.62 37.55 36.85 42.89

The Rust port ran at the same speed as the C# version (the regex-crate port was 1.02x faster than uvf). The line-for-line port was slower because it kept the design of rebuilding the regex for every file; building it once brought it level. Startup time was 1.7 ms for the Rust port, 2.7 ms for ripgrep and 4.7 ms for uvf, a gap of about 3 ms.

The one place where the Rust port was clearly faster was regexes with no required literal to pull out. Rust’s regex crate narrows lines first even on a single character or a byte sequence. Bringing that approach into the C# uvf made those patterns 2.3–6.1x faster, and [0-9]{4}-[0-9]{2} came out level with ripgrep (1.34 s vs 1.33 s). What we took home from Rust was the narrowing, not the language.

4. Where it stands now (v1.9.0, October 14, 2026)

We kept fixing things after First Light. With the current release, here is the two-run total (cold + hot) for 7 searches: plain, -i, -E, -E anchored at line start, -E -i, -v and -E -v.

7 searches, two-run total 3 GB 10 GB
Free uvf 1.08x faster than ripgrep (level) 1.08x faster than ripgrep (level)
uvp in UwView Pro (including the first run that builds the index) 3.44x faster than ripgrep 3.55x faster than ripgrep

If you search once, ripgrep is all you need. uvf is not a tool that overtakes ripgrep; it reached the same level and stopped there. uvp gets faster because the first query builds an index (.uwvz, a compressed format plus an index) and later queries read only that. Every number we measured against ripgrep is in the summary of everything we measured against ripgrep and grep.

On the command line it looks like this.

# Search once with ripgrep
rg 'Tokyo' big.xml

# The same with uvf (no index; the same conditions as ripgrep)
uvf big.xml 'Tokyo'

# The same with uvp (builds an index on the first query; faster from the second)
uvp big.xml 'Tokyo'

Exit codes follow grep: 0 = found, 1 = not found, 2 = error or incomplete result.

Where we lose or only tie

  • On the first query, ripgrep is still 6–7% faster than uvp (50 GB: 59.0 s vs 54.9–55.8 s, v1.6.6.1). That is the cost of writing the compressed index, the price of the faster later queries, and it will not go away unless the design changes. In v1.9.0, ripgrep is still 1.33x faster at 3 GB and 1.16x faster at 10 GB on the first query (both within “level”).
  • At the time of First Light, ripgrep was 1.69x faster on the 3 GB second run (plain search, 0.32 s vs 0.54 s). In v1.9.0 that flipped: uvp 0.17 s, ripgrep 0.31 s.
  • For -head, which prints only the first hits, rg | head is 1.5–6x faster. ripgrep can stop after reading what it needs; because of the index, we cannot read less.
  • On a 2-core Linux virtual machine, 3 GB is only a tie (ripgrep 1.01x faster). Expanding the index is CPU-bound, so with few cores the advantage of an index disappears.
  • The regex engine is .NET’s, so what you can write differs from ripgrep. POSIX classes ([[:alpha:]]) and \p{Han} cannot be used.
  • Almost all of these seconds come from one Mac. For Windows and Linux we only quote ratios measured on each machine (Part 12).

What to take home

  1. Count how many times you read before you suspect the algorithm. The first thing we did with 205 s was not running a profiler but counting how many times the same file was read.
  2. Measure the ceiling first. Knowing the drive’s raw read speed (950–970 MB/s) told us we could stop at 967 MB/s. A number above the ceiling is evidence of a measurement mistake, not of speed.
  3. Speeding up something outside the bottleneck does not move the clock. It can matter under other conditions, though (a second run, a faster drive).
  4. Decide what counts as a difference before you see the results. That is what keeps you from calling 1.06x a win.
  5. Suspect the language or the framework last. We stayed in C# and Avalonia and still got level with ripgrep.

The original articles

The First Light series (September 2026, v1.6)

Two articles written after it

Try UwView

Every number was measured by the developer and depends on the machine, version and date it was measured with. Results vary by environment. The ripgrep compared was 15.2.0 (15.1.0 on part of the Linux runs), and klogg was 24.11.0.1685.


From the developer: a list of my apps, Kindle books, and open source is at GitHub: amru195704.


Copied title and URL