Making Julia as Fast as C++ (2019)

(flow.byu.edu)

24 points | by d_tr 2 days ago

5 comments

  • StilesCrisis 1 hour ago
    Punchline: rewrote the code to look almost identical to C++, hand-held the compiler by adding @-marks to disable safety checks, forced SIMD codegen and fastmath on.

    End result: code that is uglier and still much slower than C++. Kind of a shame.

    • neutrinobro 8 minutes ago
      Hardly seems worth the effort, perhaps things have improved since 2019. It would be interesting to see an updated benchmark, but if your going to end up with code that looks like C++ to get proper performance, you might as well write it in C++. My biggest problem with Julia is that they decided to use column-major indexing for multi-dimensional arrays (i.e. FORTRAN/MATLAB style). This makes interoperability with C/C++ and python numpy a real pain, since you can't do zero-copy array sharing between the two without one side being forced into strided-access. For that reason alone I haven't adopted it in any of my work-flows.
    • SatvikBeri 17 minutes ago
      This is 7 years old. Julia is a totally different language by now.

      As a quick anecdote, in our take-home interview exercise, we usually receive answers in C++ or Julia, and the two fastest answers have been in Julia.

      • d_tr 1 minute ago
        > This is 7 years old.

        Yeah, I actually totally forgot to check the date...

    • 2ndorderthought 44 minutes ago
      I don't get the appeal. It's like a. OSS Matlab but all contributions are used directly so the language developers can make money for a parent company? Most OSS languages aren't run that way. Seems kind of scammy
    • brabel 56 minutes ago
      > code that is uglier and still much slower than C++.

      Oh such a shame indeed! They didn’t even manage to produce better looking code at least?? Julia was looking great in 2019 but it was very buggy still so I stopped looking. Had hopes that by now it would be a good choice over C++ and Rust with similar performance.

      • cmrdporcupine 36 minutes ago
        There's simply no way it'd ever have similar performance to those. It's not possible.

        I have always seen it as a potential alternative to Java, and definitely better than Python.

        My experience working in it professionally was that it was... fine. But the GC in it was not good under load and not competitive with Java's.

        • 2ndorderthought 13 minutes ago
          How hard was it to maintain a large Julia code base rather then say an OOP or Rust one? It has an interesting paradigm. I feel like it could get really messy
  • ForceBru 1 hour ago
  • FattiMei 56 minutes ago
    Very interesting post and I think this exposes the limitations of the Julia compiler. Note that an old version of the compiler is used (1.0.3 from 2019).

    One could say that we can almost replicate the semantic of a C++ program, but writing in Julia. For example we can remove bounds checks in arrays or remove hidden memory allocations.

    But the goal of a language for numerical computing is capturing the mathematical formulas using high level constructs closer to the original representation while compiling to efficient code.

    Domain scientists want to play with the math and the formulas, not doing common subexpression elimination in their programs. Just curious to see how it evolves

    • northzen 52 minutes ago
      I think the best compromise would be to get the best of two words. By default perform bound checks, but have a compiler flag which skips it. Might broke many programs written with default behaviour in mind, but allow perform additional optimizations.
  • slwvx 2 days ago
    From 2019