Rearchitect frontend and improve documentation and performance#33
Draft
pascalecu wants to merge 10 commits into
Draft
Rearchitect frontend and improve documentation and performance#33pascalecu wants to merge 10 commits into
pascalecu wants to merge 10 commits into
Conversation
Member
Author
|
I didn't realize the file IO stuff isn't implemented for non-{Windows,Linux} platforms. I'll roll up my own abstraction, but not now, I'll go to sleep. I could just maintain our own fork here, but I'd rather contribute to upstream. |
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.
Summary
Reduce the compiler's peak memory usage by eliminating unnecessary in-memory storage during token processing.
Also, I improved how the diagnostic engine works by doing less work, as well as the output of said diagnostics (they now take the severity into account to use an appropriate foreground color). The filesystem logic has also been migrated to use coroutines, which will be very helpful later on when dealing with multiple files and incremental parsing contexts such as LSPs. That filesystem logic is now also integrated into the source manager, where it was previously unused and a lot of duplication happened between them.
Results
Benchmarks across GCC/Clang and Debug/Release builds show:
Why
The previous implementation retained significantly more data in memory than necessary while processing tokens. This change makes the compiler process data in a more streaming-oriented manner, reducing the memory footprint without affecting observable behavior.
Benchmark configuration
Benchmarks were run:
Notes
The memory reduction is consistent across all tested configurations. Redirecting output to /dev/null also reveals measurable runtime improvements, while interactive stdout runs remain primarily limited by output overhead rather than compiler performance.
These are the raw results:
Before
After
Final notes
Sorry for the bad docs, I am tired as hell and I really want to get this over with.