Performance
Near C with every check on, and ahead of the Rust port on a real web app.
ONCE Campfire, the Egg port against the Rust port (requests/s, higher is better)
Rust Egg, each route scaled to Egg's rate
Every integer operation and every index in Egg is checked: overflow and out of bounds panic, never wrap or corrupt memory. The checks cost little. On four small programs (bench/, i7-9700K), the time relative to C:
| program | egg | rust (overflow checks on) | zig ReleaseSafe | CPython | Ruby 3.2 |
|---|---|---|---|---|---|
| fib(40) | 1.53x | 1.62x | 1.51x | 95x | 44x |
| sieve, 50M | 1.10x | 1.04x | 1.19x | 27x | 23x |
| collatz, 3M | 1.07x | 1.37x | 1.34x | 55x | 26x |
| matmul, 800×800 | 2.31x | 1.11x | 1.23x | 345x | 164x |
So Egg is 25 to 149 times faster than CPython and 21 to 71 times faster than Ruby on the same loops. matmul is behind Rust and Zig because eggc does not yet remove bounds checks from inner loops.
The HTTP example keeps up with the same
design in C and Rust, about 54,000 to 67,000 small requests per second on
loopback, against about 21,000 for Node and 8,000 for Python
(details). Go’s net/http is ahead, with far
better tail latency: Egg has blocking IO and no event loop yet.
A larger program: once-campfire-egg
ports Basecamp’s ONCE Campfire chat to Egg, measured with Basecamp’s
benchmark harness
against the Rust port, whose HTML it matches byte for byte. So far it serves
the benchmark’s routes, not the whole app. With both apps’ caches on, in
requests per second (i7-9700K, OrbStack Linux VM, app on 4 vCPUs and load
generator on the other 4, 3 alternating rounds, 16 clients; Egg at e152b5b,
Rust’s published image at 6dae2fd;
upstream PR):
| route | Rust | Egg | Egg/Rust |
|---|---|---|---|
| room page | 13,789 | 49,051 | 3.6× |
| messages page | 11,807 | 45,301 | 3.8× |
| sidebar | 12,613 | 61,308 | 4.9× |
| search | 12,620 | 52,558 | 4.2× |
| avatar | 42,810 | 56,726 | 1.3× |
| static CSS | 49,718 | 99,995 | 2.0× |
| /up | 21,688 | 120,968 | 5.6× |
| post a message | 1,452 | 2,409 | 1.7× |
Every response was valid, and the harness’s write audit verified every acknowledged post. With 1,000 WebSocket clients on one busy room, Egg delivered 209 messages/s to every client against Rust’s 186, at 47 MiB peak memory against 136.
Without its caches Egg renders and gzips every page and is far slower on them; the benchmark notes have every route and both modes.
ruby bench/run.rb # Egg, C, Rust, Go, Zig
ruby bench/run.rb --slow # also Python and Ruby (about 7 minutes)
ruby bench/http.rb # HTTP servers; needs wrk
CodSpeed also tracks the compiler’s speed, smaller versions of these programs and the CPU cost per request of the HTTP servers on every pull request (bench/codspeed/).