-
-
Notifications
You must be signed in to change notification settings - Fork 606
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
Memoize initializerSemantic #16886
base: master
Are you sure you want to change the base?
Memoize initializerSemantic #16886
Conversation
Thanks for your pull request and interest in making D better, @dkorpel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#16886" |
Could the existing PASS flags type be used instead of a bool? |
It could, but that would just add more possible invalid states to |
@@ -38,6 +38,7 @@ extern (C++) class Initializer : ASTNode | |||
{ | |||
Loc loc; | |||
InitKind kind; | |||
bool semanticDone = false; /// initializerSemantic has been run on this |
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.
Given this is a performance change, I would like to see some numbers about the tradeoff in adding additional members to a common ASTNode.
Alternately steal an unused bit from kind
for this.
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.
For some internal dub projects at SARC I tested, it shaves off about 0.8s of debug build time (19.1s => 18.3s). I doubt increasing the class instance size from 21 to 22 is a problem, it probably gets rounded up to 24 anyways because of alignment, but I can measure memory usage later.
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.
I just noticed that ArrayInitializer
already has a now redundant sem
field, and CInitializer
has an unused sem
field. Since I removed them now, memory usage might even be reduced, since those field where actually at the end, while the new semanticDone
field sits in an alignment hole, since most derived classes start with a class field with alignment 8.
81c2e20
to
9c94548
Compare
I found that on large global variables, the compiler spends lots of time creating GC pointer bitmaps by instantiating these templates in object.d:
A reduced test case is:
With templates,
initializerSemantic
is run twice, performing ctfe on a hugeArrayLiteralExp
twice as well. semantic() should be an idempotent function, and 'semanticDone' flags are already in use on Dsymbol and Expression, so this PR extends that to Initializer.