-
Notifications
You must be signed in to change notification settings - Fork 161
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
Speed up writing to global variables #3579
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.
great job! Some quick remarks, I'll have a proper look after some sleep
1e3d128
to
7f215ad
Compare
Codecov Report
@@ Coverage Diff @@
## master #3579 +/- ##
==========================================
+ Coverage 83.47% 85.05% +1.57%
==========================================
Files 693 650 -43
Lines 344698 319856 -24842
==========================================
- Hits 287749 272049 -15700
+ Misses 56949 47807 -9142
|
7f215ad
to
7bed908
Compare
7bed908
to
6193554
Compare
I ended up merging the commits in this PR together, because both of them had been changed so that the middle one wasn't actually buildable any more, and I didn't think it was worth fixing. |
6193554
to
b781452
Compare
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.
Fine by me (you may or may not want to fix that typo, it's not important)
(And by "fine by me" I obviously meant: Very nice improvement, thank you!! Obviously. Ahem. :-) |
This is done by turning WriteGVars to FlagsGVars, and storing a flag in FlagsGVars.
5263167
to
e787b0b
Compare
This PR is based around the observation that when we assign a global variable, we have to check iExprsGVar, FopiesGVar or CopiesGVar for that global variable. However, for most global variables they are set to their default values. This PR adds a single flag which tells us, for each gvar, us if any of these 3 arrays have a non-default value.
To avoid introducing another array, we take WriteGVars (which stores one of three values, if a gvar is mutable, read-only or constant), and make it into FlagsGVars, which now stores this original information, and an extra bit that tells us if any of Exprs,FOpies or Copies is not default. As we have to read WriteGVars anyway, whenever we assign a global, this means there are no extra memory lookups, just the unpacking of the flags.
For simplicity, this new bit is never cleared once it is set. This means when it is true we don't know for certain one of exprsgvar, fopiesgvar or copiesgvar is set to a non-default value, but if it is false we know they are are default.
In a tight loop assigning a global, this PR speeds things up by about 40%