In the original microbenchmarks, Julia was a bit behind C/Fortran (~1.3x) on fib(n) = n < 2 ? n : fib(n - 1) + fib(n - 2) (note this is 64-bit on Julia, 32-bit on the others, but making fib type-generic didn’t make a difference for me). The most plausible explanation I could find was that non-inlined function calls have extra overhead for the GC, and it’s especially apparent in this benchmark where such calls are cheap and numerous by design. There are other microbenchmarks where Julia falls behind another language, but the function call overhead caught my eye.
The gap has widened to ~3.3x and ~4.9x, so I’m starting to doubt that explanation (why would our GC need more overhead, how is Fortran getting ahead?). I wouldn’t understand how the differences in assembly matter, so I’m asking for some insights. I don’t know where to find or how to reproduce these benchmarks at other points in time, so I don’t know when the gap started widening.
Here are the select numbers and links I got them from.
The updating Benchmarks · Julia Microbenchmarks, C/Fortran (gcc 13.3.0), Julia 1.12.5, GitHub Actions ubuntu-latest x86_64 (I don’t know the specifics):
| Language | fib(20) time (ms) |
relative to C | relative to best (Fortran) |
|---|---|---|---|
| C | 0.012957 | 1.0 | 1.465 |
| Fortran | 0.008844 | 0.6826 | 1.0 |
| Julia | 0.043365 | 3.3468 | 4.903 |
The old static Julia Micro-Benchmarks, C/Fortran (gcc 7.3.1), Julia v1.0.0, openSUSE LEAP 15.0 Linux, Intel® Core™ i7-3960X 3.30GHz CPU, 64GB 1600MHz DDR3 RAM:
| Language | fib(20) time (ms) |
relative to C | relative to best (Fortran) |
|---|---|---|---|
| C | 0.022732 | 1.0 | 1.0118 |
| Fortran | 0.022466 | 0.9883 | 1.0 |
| Julia | 0.030162 | 1.3269 | 1.3426 |