gflow.d: double speed of fillInDNunambig()#12459
Conversation
|
Thanks for your pull request, @WalterBright! 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#12459" |
|
Hmm, it passes on my local machine. |
13bd083 to
cf8d9ad
Compare
cf8d9ad to
ad3d9f7
Compare
|
Looks like adding that check was a good idea, it found two bugs in the new version. |
Why is this necessary? How does this help performance?
It's green now. |
Originally the nested foreach loop of |
src/dmd/backend/gflow.d
Outdated
| * result from the previous implementation. (I already botched it once.) | ||
| * After it passes, remove. | ||
| */ | ||
| version = CheckAgainstOldMethod; |
There was a problem hiding this comment.
I guess this can be disabled now.
|
I've posted a rough draft of a more linear solution here: Once the hash helper functions are moved to an appropriate location, the resulting body of It doesn't solve extreme degenerate cases such as https://issues.dlang.org/show_bug.cgi?id=7157 but it should out do this solution. |
|
Bench 1 (Re-running because I'm getting different results now - I guess the background noise on my machine must be busier than usual)
At best, it's a marginal gain. Should really profile it to drill down a bit more on the lowest hanging fruit. As fixing this function isn't giving a satisfying boost, if the goal is to be as fast as gdc. |
True, it is simply the easiest of the problem functions to improve (i.e. a first step,) I'm planning to tackle the other O(N^2) backend functions mentioned in https://issues.dlang.org/show_bug.cgi?id=6401#c4 :
It all boils down to using hash tables instead of O(N) search for each of the problem functions. |
|
ping @WalterBright |
|
@WalterBright what are your plans with this PR? |
|
ping @WalterBright |
ad3d9f7 to
85cdec9
Compare
|
I recommend pulling this and then when @WalterWaldron 's solution is ready, pull that one. |
|
Thanks! |
@ibuclaw notes its quadratic performance here https://issues.dlang.org/show_bug.cgi?id=6401#c4
This change doubles its speed by noting that the matrix it creates is symmetric, so no need to redo half the work. But it's still quadratic.
The change:
startrather than 0It isn't obvious that it is correct. So I added a check that computed the vectors the old way, and compared for identity with the new results. After it passes, this check can be deleted as being too expensive.