Live data from Hacker News

Tilde, My LLVM Alternative

yasserarg.com

141–150 of 165 posts

Re: Tilde, My LLVM Alternative

#141
post #137

Earlier quoted context omitted.

I'm very confused what magic you believe will achieve what has not so far been achieved. I'm also confused why you believe LLVM didn't start out the exact same way? I say this as one of the main people responsible for working on combined pass replacements in both GCC and LLVM for things that were reasonable to be combined. I actually love destroying lots of passes in favor of better combined ones. In that sense, i'm…

Critical responses from people in the industry are what I come here to read. I have no doubt of your credentials and I'm not at all qualified to judge the technical details here, but your reply comes off as an emotional kneejerk. I read it a few times and as best I can get this is what you're saying: - You came up with a similar combined replacement pass for LLVM based on years of personal and external research. - It…

" but your reply comes off as an emotional kneejerk."

Lots of these come by, it gets tiring to try to provide detailed critiques of all of them. Feel free to go through comment history and see the last one of these to come along and the detailed critiques there :)

Meanwhile, let me try to help more:

First, the stuff i'm talking about is released. It's been released for years. It is included in LLVM releases. None of this matter, it was an example of what it actually takes in terms of time and energy to perform some amount of pass combination for real, which the author pays amazingly short shrift to.

I chose the example I did not because i worked on it, because it's in the list of things the author thinks are possible to combine easily!

Second it's not one combined pass they have to make - they think they will turn 75 passes into 20, with equivalent power to LLVM, but somehow much faster, yet still maintainable, mainly because "it's time for a rewrite" and they will avoid 20 years of cruft.

So they don't have to repeat the example i gave once. They have to repeat it 20-30 times. Which they believe they will achieve and reach maturity of in ... a few years.

They give no particular reason this is possible - i explained why it is remarkably difficult - while certainly you can combine some dataflow optimizations in various ways, doing so is not just hacking around.

It's often hard computer science problems to take two optimization passes, combine them in some way, and prove the result even ever terminates, not even that it actually optimizes any better. Here they are literally talking about combining 3 or 4 at a time.

While there are some basic helpful tools we proved a long time ago about things like composability of monotonic dataflow problems, these will not help you that much here.

Solving these hard problems are what it takes to have it work. It's not just cherry picking research papers and implementing them or copying other compiler code or something.

Let's take a concrete example, as you request:

If you want to subsume the various global value numbering passes, which all eliminate slightly different redundancies and prove or otherwise guarantee that you have actually done so, you would need a global value numbering pass you can prove to be complete. Completeness here means that it detects all equivalent values that can be detected.

There is no way around this. Either it subsumes them or it doesn't. If it doesn't, you aren't matching what LLVM's passes do, which the author has stated as the goal. As I said, i could believe a lesser goal, but that's not what we have here.

The limit of value numbering completeness here was proved a long time ago. The best you can do is something called herbrand equivalences. Anything stronger than that can't be proven to be decidable, and to the degree it can, you can't prove it ever terminates.

That has the upside that you only have to achieve this to prove you've done the best you can.

It has the downside that there are very few algorithms that achieve this.

So there are a small number of algorithms that have been proven complete here (about 7) - and all but 3 have exponential worst time.

The three polymonial algorithms are remarkably complicated, and as far as i know, never been implemented in any production compiler, anywhere. Two are N^4, and one is N^3.

One of the N^3 ones has some followup papers where people question whether it really works or terminates in all cases.

These are your existing choices if you try to use existing algorithms to combine these 4 out of the 70 passes, into 1 pass.

Otherwise, you get to make your own, from scratch.

The author seems to believe you can still, somehow, do it, and make the result faster than the existing passes, which, because they do not individually try to be complete, are O(N) and in one case, N^2 in the worst case. So combined, they are N^2.

While it is certainly possible to end up with N^3 algorithms that are faster than N^2 algorithms in practice, here, none of the algorithms have also ever been proven practical or usable in a production compiler, and the fastest one has open questions about whether it works at all.

Given all this, i see the onus as squarely on the author to show this is really possible.

Again, this is just one example of what it takes to subsume 4 passes into 1, along the exact lines the author says they think they will do, and it would have to be repeated 30 more times to get down to 20 passes that are as good as LLVM.

That's without saying anything else about the result being faster, less complex, or having less cruft.

As for whether they've accomplished a combined pass of any kind -I've looked at the code in detail - it implements a fairly basic set of optimization passes that nowhere approaches the functionality of any of the existing LLVM passes in optimization power or capability. It's cool work for one person, for sure, but it's not really that interesting, and there are other attempts i would spend my time on before this one. I don't say that to knock the author - i mean it in the literal sense to answer your question - IE It is not interesting in the sense that there is nothing here that suggests the end result will achieve fundamental improvements over LLVM or GCC, as you would hope to see in a case like this. The choices made so far are a set of tradeoffs that have been chosen before in other compilers, and there is nothing (yet) that suggests it will not end up with similar results to those compilers.

It is any not further along, more well developed, etc, than other attempts have been in the past.

So when I look at it, i view that all as (at least so far) not interesting - nothing here yet suggests a chance of success at the goals given.

As I said, these things come along not infrequently - the ones that are most viable are the ones that have different goals (IE fast compilation even if it does not optimize as well. Or proven correct transforms. or ...). Or those folks who think they can do it, but it will take 10-15 years. Those are believable things.

The rest seem to believe there are magic bullets out there - that's cool - show me them.

As for " Pretty much all projects and startups fail, but it's because people attempt them that some succeed."

This is true, but also tautological, as you know - of course things can only succeed if someone attempts them. It is equally as true that just because people attempt things does not mean anyone will succeed. While it is true nobody will be able to breathe unassisted in space if nobody tries, that does not mean anyone can or will ever succeed at it no matter how many people try.

This case is not like like a startup that succeeds because it built a better product. This is like a startup that succeeds because it proved P=NP.

Those are not the same kind of thing at all, and so the common refrains about startups and such are not really that useful here.

The one you use is useful when arguing that if enough people try to build a better search and outdo Google (or whatever), eventually someone will succeed - this is likely true.

In this case, however, it is closer to arguing that if enough people jump off 500ft cliffs and die, eventually someone will achieve great success at jumping off 500ft cliffs.

Re: Tilde, My LLVM Alternative

#142

Earlier quoted context omitted.

Back 20 or more years ago I used to do a lot of rec math competition programming and found that the metrowerks c++ compiler made massively faster programs than gcc, vsstudio, intel and everything else I tried then. This seemed to be simply down to variable alignment; the programs took more memory but ran much faster, particularly multi-core (which was still high end then). And this was on x86 where metrowerks weren't…

Memory access patterns are everything. Memory delay is almost always the bottleneck anyway. I have the feeling that more and more this is becoming common knowledge, and techniques like "struct of arrays" are becoming more wide spread and talked about.

Is this perhaps why Build Engine used arrays, rather than arrays of struct? Organising things columnwise rather than rowwise, like an OLAP engine? https://fabiensanglard.net/duke3d/code_legacy.php

Re: Tilde, My LLVM Alternative

#143

Earlier quoted context omitted.

Memory access patterns are everything. Memory delay is almost always the bottleneck anyway. I have the feeling that more and more this is becoming common knowledge, and techniques like "struct of arrays" are becoming more wide spread and talked about.

Is this perhaps why Build Engine used arrays, rather than arrays of struct? Organising things columnwise rather than rowwise, like an OLAP engine? https://fabiensanglard.net/duke3d/code_legacy.php

Yes. We learned that pattern in University, it is usually worth it unless in a high-level language.

Re: Tilde, My LLVM Alternative

#144
post #12

Earlier quoted context omitted.

It is pretty much Visual Studion on Windows and XBox, Nintendo and Sony have clang forks. Embarcadero owns Borland, unfortunely stuff like C++ Builder doesn't seem to get much people outside big corps wanting to use it, which is a shame given its RAD capabilities and GUI design tooling for C++. Also has a standard ABI between Delphi and C++ Builder, which allows to similar development workflows that .NET offered late…

Borland as of a few years ago also ships a clang fork for C++ Builder, interestingly enough. It unfortunately does not solve all of the problems you encounter using C++ Builder in the modern age. I’ve personally watched the enshittification of too many proprietary tools to ever build something I care about on top of one today, especially something which becomes so fundamental to the design of your application like a…

Yes, they do, but are still not done adding all the necessary C++ Builder sugar, that makes their tooling great, although almost there as of last year's release.

Re: Tilde, My LLVM Alternative

#145
post #66

Chris Lattner seems to have also created an alternative for LLVM - https://mlir.llvm.org/ Because of how the architecture works, LLVM is one of the backends, but it doesn't have to be. Very interesting project, you could do a lot more IR processing before descending to LLVM (if you use that), that way you could give LLVM a lot less to do. Chris has said LLVM is fast at what it is designed to do - lower IR to machine…

I wonder if this question can attract any MLIR people to answer my question: From Chris Lattner's descriptions of LLVM vs MLIR in various podcasts, it seems like LLVM is often used as a backend for MLIR, but only because so much work has been put into optimizing in LLVM. It also seems like MLIR is strictly a superset of LLVM in terms of capabilities. Here's my question: It seems inevitable that people will eventually…

MLIR maintainer here, or however close one can be given that we don't have a clear ownership structure. This has been discussed repeatedly in the community, and it is likely that many things will get eventually ported/reimplemented, but there is no strong push towards that. Lower level parts of the stack, such as register allocation / machine IR / instruction selection are where LLVM has seen a lot of investment are unlikely to move soon. At least not in a generic way.

There was a keynote at the LLVM developer meeting a couple of years ago presenting the differences and the likely evolution from somebody not involved in MLIR that does the lay of the land.

Re: Tilde, My LLVM Alternative

#146
post #81
post #66

Earlier quoted context omitted.

I wonder if this question can attract any MLIR people to answer my question: From Chris Lattner's descriptions of LLVM vs MLIR in various podcasts, it seems like LLVM is often used as a backend for MLIR, but only because so much work has been put into optimizing in LLVM. It also seems like MLIR is strictly a superset of LLVM in terms of capabilities. Here's my question: It seems inevitable that people will eventually…

All the important bits of MLIR are closed source and there’s no indication that’ll change anytime soon. The big players have their own frontend, dialects, and mostly use LLVM backends. There’s very little common usable infrastructure that is upstreamed. Some of the upstreamed bits are missing large pieces.

I'd be interested to learn about such closed-source important bits and invite them to MLIR workshop / open developer meeting. Having worked on the project essentially since its inception, I am quite positive that the bits the original MLIR team considered important are completely open source.

Certainly, there are closed-source downstream dialects, that was one of the actual design goals of the project, but they are rarely as useful as one might think. I'd expect every big company with a hardware to have an ISA/intrinsic-level dialect, at least as a prototype, that they won't open source for the same reason they won't open source the ISA.

What I find sad is the lack is that end-to-end flows from, e.g., PyTorch to binaries are usually living outside of the LLVM project, and often in each company's downstream. There is some slow motion to fix that.

Re: Tilde, My LLVM Alternative

#147
post #10

Again, somebody who comes to the realization something is seriously wrong with ultra-complex languages in the SDK (c++ and similar). In other words, since this alternative LLVM is coded in plain and simple C, it is shielded against those who are still not seeing that computer languages with an ultra complex syntax are not the right way to go if if want sane software. You also have QBE, which with cproc will give you…

What's kind of amazing is those people who are "I wrote a small C compiler" and advocating for ultra-complex-syntax computer languages: They know they could _NOT_ have said "I wrote a ultra-complex-syntax computer language compiler"...

Re: Tilde, My LLVM Alternative

#148
post #133

Is it just me or I find it difficult to believe that 19 year olds can implement the LLVM alternative?

Just you. The best programmers I've known were about that age. (Hell, I'm pretty sure my own peak programming years were about that age)

Same, early 20s.

Why though, it seems with time we learn a LOT more and then there are 100 ways of doing things and get into analysis paralysis. The passion hasn't been the same as well.

Re: Tilde, My LLVM Alternative

#149
> a decent linear scan allocator which will eventually be replaced with graph coloring for optimized builds.

Before setting out to implement 1980s-style graph coloring, I would suggest considering SSA-based register allocation instead: https://compilers.cs.uni-saarland.de/projects/ssara/ , I find the slides at https://compilers.cs.uni-saarland.de/projects/ssara/hack_ssa... especially useful.

Graph coloring is a nice model for the register assignment problem. But that's a relatively easy part of overall register allocation. If your coloring fails, you need to decide what to spill and how. Graph coloring does not help you with this, you will end up having to iterate coloring and spilling until convergence, and you may spill too much as a result.

But if your program is in SSA, the special properties of SSA can be used to properly separate these subphases, do a single spilling pass first (still not easy!) and then do a coloring that is guaranteed to succeed.

I haven't looked at LLVM in a while, but 10-15 years ago it used to transform out of SSA form just before register allocation. If I had to guess, I would guess it still does so. Not destroying SSA too early could actually be a significant differentiator to LLVM's "cruft".

Re: Tilde, My LLVM Alternative

#150

> a decent linear scan allocator which will eventually be replaced with graph coloring for optimized builds. Before setting out to implement 1980s-style graph coloring, I would suggest considering SSA-based register allocation instead: https://compilers.cs.uni-saarland.de/projects/ssara/ , I find the slides at https://compilers.cs.uni-saarland.de/projects/ssara/hack_ssa... especially useful. Graph coloring is a nice…

Also, for a different notion of "cruft", informally it seems to me like new SSA-based compilers tend to choose an SSA representation with basic block arguments instead of the traditional phi instructions. There are probably reasons for this! I'm not aware of a Sea of Nodes compiler with (some notion corresponding to) block arguments, but it might be fun to explore this when designing a new compiler from the ground up. Might be too late for TB, though.
Post reply on HN