-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store expansion locations separately from tokens #623
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Another quick memory optimization would be to add a clearBuffers
function that could be called at the end of preprocessSources
.
Merge at will.
Updated benchmark with
zig2.c: Maximum resident set size (kbytes): |
The main insight here is that most tokens don't have expansion locations; and that expansion locations are (currently) only used for diagnostic messages, so "slow" lookups are not a problem. Since tokens are always inserted in-order by the preprocessor (sorted by construction), we can store token index + expansion locations in a MultiArrayList and binary search for a token index when we want the corresponding expansion locations.
sqlite benchmark:
I wasn't able to use
poop
withzig2.c
because of some<quadmath.h>
shenanigans (which I don't fully understand, but that's a separate issue). However using/usr/bin/time
I was able to measure the max RSSMaster branch: Maximum resident set size (kbytes):
1377964
This PR: Maximum resident set size (kbytes):
1195260
(Difference of
187,088,896
bytes)