Rust is my favorite programming language, but its compiler is noticeably slow. There are plenty of incredibly talented people working on improving rustc
, and compilation speed is important to them too. At this point, if a change to a single function could noticeably improve performance, it's already implemented. Meaningful improvements are now coming from changes to APIs and data structures, which are significantly harder to evolve. In a large codebase like rustc
, where many features are worked on simultaneously and there is a need for stability, making these large-scale changes is effectively impossible. I'm deeply appreciative of the people who find ways to slowly and incrementally pushing these changes through, but I want to take a different approach.
I find compiler architecture fascinating, and I hypothesize that the only way to radically improve compilation performance is to rethink how we design compilers entirely. No matter the target language, large-scale architectural optimizations are always waiting to be uncovered. This may feel more obvious for simple(r) languages like C, but I want to demonstrate that it can extend all the way to the other end of the spectrum, to Rust. The resulting design might be specific to the target language, but it is always valuable to learn from.
Krabby is a blank-slate implementation of a Rust compiler, designed with performance as a priority. It has fundamentally different goals from rustc
; it is a small codebase controlled by a single individual, where stability is not a concern. By designing every component with all other components in mind, I hope to find new optimization opportunities and to end up with a more cohesive architecture as a whole.
To call this a massive project would be an understatement. I don't know how likely I am to finish it. I don't even know whether I'm the right person to take on such a project. But I absolutely love the process of optimizing and perfecting code, and thus far, the joy of writing good code (especially for a cause I find worthwhile) is sustaining me pretty well.
The code is hosted on SourceHut. I plan to post about my progress relatively often (at least once every one or two weeks) on Mastodon, and I will post longer-form updates with more depth here. If this is a project you find interesting, get in touch; I'd love to hear from you!