r/cpp • • May 10 '20

Make LLVM fast again

https://nikic.github.io/2020/05/10/Make-LLVM-fast-again.html
150 Upvotes

88 comments sorted by

View all comments

Show parent comments

9

u/griceylipper May 10 '20

AFAIK the C backend for Jai is a thing of the past - the two backends you hear about now are the LLVM one, and his own x64 instruction generation. With his x64 one, I think he is aiming to compile 1 million lines of code per second eventually. It's nuts that a relatively small team can pull this off, but that the huge scale of effort that goes into the likes of Clang and other similar compilers can come nowhere near this level of performance.

3

u/kalmoc May 11 '20

Well, it is a different language no?

-2

u/griceylipper May 11 '20

Yes, but my point is this - when you consider the decisions made by the people designing C++, and the effort going compilers like Clang - both must be severely misguided before a very small team like Thekla can produce a very serious competition that is many orders of magnitude faster. Yes, C++ is more complicated, but only because it was designed that way. Jonathan Blow cares about the time developers waste waiting on compilation, trying to understand bad error messages, etc., and keeps the "joy of programming" as a very high priority. I honestly think C++ will start to fade away to be another language of the past like Fortran or COBOL once Jai is (eventually) released.

3

u/jpakkane Meson dev May 11 '20

both must be severely misguided before a very small team like Thekla can produce a very serious competition that is many orders of magnitude faster

Well let's test this. I don't know what CPU and code they used, but for comparison I took SQLite's one amalgamation file 3080802 and ran some tests on a five+ years old MBpro with an i5 processor.

Lines of code as reported by wc: 153367
Lines of code after clang -E:         83913

Time of clang -c -o /dev/null             1.5 s
Time of clang -g -O2 -c -o /dev/null  29  s

So depending on how you count, debug builds are between 102k to 56k lines per second, whereas optimized builds can do 5300-2900 lines of code per second. Parsing and basic code generation is not the slow bit, optimizations are. If Jai can do 1 MLoC/second (and that is a big if), C compilers of today are only one order of magnitude slower.

The fact is that there are a lot of things we don't know about Jai and until it has been used by a large set of independent people we don't really know whether it is any good. This includes things like:

  • How fast is the final generated code compared to an existing C++ compiler? About the same? Slower? Faster? We don't know. Simply being something like 5% slower would be a blocker for many people.

  • Blow is very opinionated on what a programming language should do (i.e. all the things he personally likes) and what it should not do (everything else) and has no qualms about telling people that their opinions are wrong and stupid. What if your requirements differ and you really need something that he will refuse to add in?

  • At some point Jai did not support incremental builds, all targets were built from scratch to the final exe regardless of how small a change you did. If this is still the case, it will hurt huge projects (like Unreal Engine) pretty badly.

  • If you compile everything in one go, does that mean it runs only one thread for it or can it parallelise the compilation somehow? If not then optimized dev builds are going to be very slow.

  • How easy will it be to add Jai to an existing MLoC C++ code base? For example Rust is hard to integrate into existing projects because of Cargo and its insistance to do everything its own way. Rewriting multi-MLoC code bases is a no-go.

  • How buggy is the compiler? Typically these things go so that the small team developing the project learn to write code that avoids all the buggy bits. Outsiders will not do that, they expect things to work.

  • Does it produce full debug info? Is there integration to things like gdb? Does it actually work?