DEV Community

Discussion on: Performance Comparison, Rust vs Crystal with Redis

Collapse
 
hnicolas profile image
Nicolas Hervé

Maybe a long running process will show a decrease in Crystal performance due to the garbage collector.

Collapse
 
asterite profile image
Ary Borenszweig

The GC is already running in the benchmark here. My guess is that Crystal actually allocates less memory than Rust for some reason (maybe the Rust client isn't well optimized).

Collapse
 
jgaskins profile image
Jamie Gaskins

I wrapped the Redis pipeline code to run it 10x in the same process, so it runs 4 million commands in 10 pipelines, but it didn't make any significant changes to how long it took for either app. The results are below, but to summarize: it makes the CPU-time ratio 3.13 CPU seconds for Rust vs 1 CPU second for Crystal, tipping the scales even more in Crystal's favor.

$ time target/release/examples/redis_app
553
543
534
538
540
529
524
532
528
536
target/release/examples/redis_app  2.82s user 0.31s system 49% cpu 6.279 total
Enter fullscreen mode Exit fullscreen mode
$ time bin/bench_redis
00:00:00.324824666
00:00:00.316971548
00:00:00.316958306
00:00:00.316820546
00:00:00.316534462
00:00:00.318077670
00:00:00.322508686
00:00:00.322692871
00:00:00.321157067
00:00:00.315688903
bin/bench_redis  0.94s user 0.06s system 30% cpu 3.298 total
Enter fullscreen mode Exit fullscreen mode