From 100x Slower Than Rust to Beating It: The coregex Journey

A few days ago, @kostya27 posted on r/golang (124 upvotes): "Why is Go's regex so slow?" Go total time on LangArena: 116.6 seconds. Without two regex tests: 78.5 seconds. Without regex, Go is compe...

By · · 1 min read
From 100x Slower Than Rust to Beating It: The coregex Journey

Source: DEV Community

A few days ago, @kostya27 posted on r/golang (124 upvotes): "Why is Go's regex so slow?" Go total time on LangArena: 116.6 seconds. Without two regex tests: 78.5 seconds. Without regex, Go is competitive with Rust/C++. With regex, it's not even close. He's right. And this post is about what we did about it. Six months ago, I wrote about building coregex — a regex engine for Go that's 3-3000x faster than stdlib. The benchmarks looked great. Then reality hit. @kostya, author of LangArena (2,900+ stars on GitHub), tried coregex on his benchmark suite. His verdict: "I tried coregex, but no luck." His numbers told the story: Benchmark Go stdlib coregex v0.12.8 Rust regex PCRE2 JIT LogParser (13 patterns) 22.7s 22.0s 0.2s — Template::Regex 6.5s 7.0s 3.8s 1.0s We were 100x slower than Rust on LogParser. On the same machine. Same input. Same patterns. Our "3000x faster than stdlib" claim? True — on many patterns we tested. But we had blind spots we didn't know about: case-insensitive patterns,