Separate semantic routines from expression.d#7031
Conversation
|
Thanks for your pull request, @RazvanN7! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Some tips to help speed things up:
Bear in mind that large or tricky changes may require multiple rounds of review and revision. Please see CONTRIBUTING.md for more information. 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. |
ac28efa to
ac7c6be
Compare
|
I was a bit worried about the compilation overhead due to the extra function call, so I made some measurements: I timed the standard make -f posix.mak for druntime and phobos (10 times each, for each version) and the results show that the overhead is completely neglectable. Compiling druntime: master: PR: Compiling phobos: master: PR: |
|
Nice! I'm a bit worried about the minima for druntime, but those for phobos look good. @WalterBright are these the droids you're looking for? |
|
Nice work, but the 4% slowdown is a bit disheartening. Andrei, is there another way to do the visitor pattern? |
|
The entrypoint semantic function should be exposed to c++ perhaps as an interim, otherwise how am I going to be able to call it? |
|
Or maybe there should be a global function table that exposes these entrypoint routines to C++. |
|
@andralex @WalterBright the minima for druntime on master (7.168 s) was obtained only once and the rest 9 measurements were 8,3.. . It is very possible that the difference is due to operating system specifics and not compilation overhead. Anyway, using the visitor pattern implies two function calls (double dispatch), so the only workaround for this would be to just get rid of the visitor and implement the semantic methods as an overload set, but that might be complicated given the inheritance relationship between classes. |
|
@ibuclaw If this PR is merged, I was thinking of creating a file named semantic.d which imports all the *sem.d modules and creates an overload set with the semantic routines from all those modules. After this is done, I will create the semantic.h file which has the headers. How's that? |
The obvious way to do it is to (a) leave all semantic-related member variables in the respective classes, and (b) collect all semantic function implementations in a module. The latter is possible in C++ but not in D (you can't define a method out-of-class). There are of course obvious disadvantages, but that would only cost one virtual call. But let's take a second look at the measurements as it's very important how they're conducted.
(I assume measurements were conducted on the same OS so not sure I get the last sentence.) In the presence of noise, the best way to measure differences in timings is to run both experiments very many times and then compare the modes (mode = the point where the density of samples is the highest). But getting a reliable mode would necessitate a bunch of experiments i.e. a long time. A possibility is to look at the same order statistic (e.g. median, 90 percentile etc). Again that takes a fair number of measurements to get. So then we go with the notion that the noise is fluctuating, occasional, and always additive (no noise reduces computation time). By that hypothesis we get to the conclusion that mode is close to the shortest time, because that is the one least affected by noise. Even if noise is not occasional, the minimum is most indicative of the computation itself. That's why comparing minima is better than the average (VERY noisy). I ssh'd into a quiet machine otherwise unused and ran the following experiments: For master I got: For this patch I got: For master I got a minimum of 5.477 seconds per build. For this patch I got a minimum of 5.472 which is essentially identical. My conclusion is there's no need to worry about a performance loss with this PR. |
The measurements were made on the same OS but it is possible that due to some OS favorable situation (for example: fewer context switches, smaller I/O waiting times etc) the minimum was obtained in exceptional circumstances. |
|
The rule of thumb wrt additive noise is there are exceptional maxima but not exceptional minima. Low minima should be reproducible. Nicely enough they are! |
| import ddmd.errors; | ||
| import ddmd.expression; | ||
| //import ddmd.expressionsem; | ||
| import ddmd.expressionsem; |
src/ddmd/expressionsem.d
Outdated
| } | ||
|
|
||
| // Check for call operator overload | ||
| if ( |
There was a problem hiding this comment.
@ibuclaw If this PR is merged, I was thinking of creating a file named semantic.d which imports all the *sem.d modules and creates an overload set with the semantic routines from all those modules. After this is done, I will create the semantic.h file which has the headers. How's that?
It doesn't help that semantic itself is not extern(C++).
|
Just the function semantic itself needs to be marked as extern(C++). Variants can remain hidden. |
ac7c6be to
fefcf81
Compare
|
@andralex I marked the semantic routine as |
|
Please rebase |
Looks ok to me. |
fefcf81 to
53aad37
Compare
53aad37 to
5ebbc87
Compare
|
@WalterBright actually we can be the vistors faster by using the op-field or perferbly by storing a type-enum in However the alternative which is keeping the virtual functions for theese things which users are unlilkely to ever hook into is much prefered! |
|
secondly WHY WAS THIS MERGED ???? |
|
@UplinkCoder we are converting virtuals to visitors for compilation steps in order to improve modularity and coupling. I understand this breaks a bunch of ongoing PRs, but it's a cost @WalterBright and I decided is worth taking. Apologies for the extra churn. |
We should probably think about packaging these modules perhaps (
We should also dedicate a week to going through these as we do with bugzilla reports. Take ownership of and rebase, or close all PRs below 4000, for instance. |
This PR continues the work started in [1] and continued in [2] by separating the semantic routines from the ast nodes for expression nodes.
[1] #5730
[2] #7007