Add benchmarks for experimental and make the compiler 2x faster#692
Open
Add benchmarks for experimental and make the compiler 2x faster#692
experimental and make the compiler 2x faster#692Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I added some simple benchmarks, which compile the googleapis Buf module in a number of different settings. This allowed me to stare at flame graphs really hard and remove various bottle necks (or places where Go failed to optimize correctly).
This mostly involved chasing down places where Go failed to inline, devirtualize, or stack-promote. Including the new interning algorithm, the experimental compiler is now on-par with the old compiler. Hot recompiles are, unsurprisingly, orders of magnitude faster, something we've already seen in LSP.
With my optimizations, the lion's share of work is actually in building
FileDescriptorProto, which is not currently parallelized. Building a googleapis FDP withSourceCodeInfotakes about a full second, compared to less than a second to do in-memory linking. 60% of that is generating theSourceCodeInfo.Other fun facts:
internal/trie.One concerning thing I noticed, which I kind of expected, is that most things that return
seq.Indexerseem to inline, but then their return values escape to the heap anyways. It's not clear to me what the cause is. I suspect thatseq.Valuesis the culprit, and there may be a Go compiler bug around devirtualization here. I probably need to stare at the assembly to puzzle it out.