“ as some keen HN commenters have pointed out, it looks like the rust program is not actually equivalent to the go program. The go program parses the string once, while the rust program parses it repeatedly inside every loop.”
In general for most long lived workloads, I would expect Go to be approximately 15-25% slower than an equivalent C/C++/Rust program because of the CPU overhead of the Go GC. The Go team have done a lot of great work to optimize pause times and memory consumption though.
See the discussion around it and the patches made by the community and the final results.
See the individual benchmarks: https://github.com/christianscott/levenshtein-distance-bench...
hyperfine go/out 'node javascript/main.js' rust/target/release/rust 1 Benchmark #1: go/out
Time (mean ± σ): 1.888 s ± 0.013 s [User: 2.040 s, System: 0.045 s]
Range (min … max): 1.875 s … 1.918 s 10 runs
Benchmark #2: node javascript/main.js Time (mean ± σ): 4.257 s ± 0.033 s [User: 4.295 s, System: 0.042 s]
Range (min … max): 4.221 s … 4.338 s 10 runs
Benchmark #3: rust/target/release/rust Time (mean ± σ): 874.1 ms ± 50.8 ms [User: 5.688 s, System: 0.830 s]
Range (min … max): 813.5 ms … 1001.9 ms 10 runs
Summary 'rust/target/release/rust' ran
2.16 ± 0.13 times faster than 'go/out'
4.87 ± 0.29 times faster than 'node javascript/main.js'That PR does not make the benchmark loads "equivalent." Please look at the diff. That PR adds parallelism to the Rust program. The Go program does not have parallelism.
Never felt about it this way.
And it's true that if you think of allocations as being no big deal unless you're aiming for very high performance, your Rust is going to be slow (also your C++ and your C).
http://dtrace.org/blogs/bmc/2018/09/28/the-relative-performa...