-
-
Notifications
You must be signed in to change notification settings - Fork 636
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
Cache the result of FuncDeclaration.isTypeIsolated()... #12930
Cache the result of FuncDeclaration.isTypeIsolated()... #12930
Conversation
Thanks for your pull request and interest in making D better, @JohanEngelen! 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#12930" |
I don't like the addition of global variables. Have you tried caching based on |
This is not an objective critism that I can remedy.
This won't work without string copying in
I will try it, give me a few days. (Nice to see you are using --ftime-trace and that you are putting it to good use! :-) hope you like the improvements of ldc-developers/ldc#3797 !) |
|
Why do you need to copy it? It's interned, meaning it's immutable and two
It's a useful feature, thanks for adding it! |
@JohanEngelen : @dkorpel is right, the entire point of deco is to provide fast comparison of types. This makes it the faster alternative and gets rid of the need to add a new field. |
!!! |
How true is this? |
You forgot one more exclam! Yeah, the impact is huge. |
I'm fairly certain they are unique. The copy() functions returns a new type that has not gone through semantic analysis. During semantic analysis of the type itself, the uniqness is assured. |
Looks like we are down to 1m49 currently (just sema, no codegen).
I don't understand why this is being debated. We need a unique identifier for |
It's debated because re-inventing an existing mechanism in the compiler with a global variable adds complexity to the code. I agree that |
Thank you! This is very interesting, I expected the codebase would contain a few complex base classes that would take >1s for each |
My "without any of this" was actually including the change in |
|
Is the codebase compiled with |
I see your point now, you don't want to rely on the fact that dmd interns .deco strings in |
src/dmd/mtype.d
Outdated
@@ -247,6 +247,12 @@ extern (C++) abstract class Type : ASTNode | |||
MOD mod; // modifiers MODxxxx | |||
char* deco; | |||
|
|||
// Each Type gets a unique identifier stored in uniqueId during compilation (automatically set by constructor). |
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.
Each Type already gets a unique identifier - it's the .deco
field.
It absolutely is meant to be a unique identifier, and is used as such everywhere. For example, because these identifiers are unique, types can (and are) compared for identity by comparing the pointers to |
I was looking at
|
Looking at the implementation if
which is going to be disastrously slow, and consume lots and lots and lots of memory. It's then inserted into an associated array. |
I suggest |
@JohanEngelen Are you now convinced that deco can be used as a unique identifier? If so, could you update this PR so that we can move forward? |
@RazvanN7 @JohanEngelen ping pong |
@maxhaton I will happily merge this once the comments have been addressed and the conflicts resolved. |
haven;t gotten around to testing with the changes yet |
153cf72
to
871b285
Compare
…tentially a very expensive check.. This resulted in a large compile-time improvement on the large codebase at Weka.io (11min --> 3.5min).
871b285
to
d38cc83
Compare
What results are you getting now? This seems to yield about 5% on some informal testing for me, does that correlate? I haven't tried it on any internal company things but I imagine it'll be similar |
I cannot test using dmd master (will take months before we get there, no joke). Edit: and 5% is huge. |
Did you use any profiling tools to figure this out? If so, which? |
The improvement is not so large anymore (codebase has evolved, see a later post in this thread here), but initially it was huge. I believe Eyal found the offending code using |
ping |
...because it is potentially a very expensive check.
This resulted in a large compile-time improvement on the large codebase at Weka.io (11min --> 3.5min).
Patch by @EyalIO !