-
Notifications
You must be signed in to change notification settings - Fork 571
Faster warnDuplicateRefs #3899
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
Faster warnDuplicateRefs #3899
Conversation
There are a few other
Since these don't preserve all duplicates, I'm wondering if this would also fix #3884 |
Is Also, it seems like the code for the purescript/src/Language/PureScript/AST/Declarations.hs Lines 335 to 358 in 9cad73e
|
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.
Thanks, this looks great. I noticed this is pointed at the 0.13.x release branch. Shouldn't we be commiting to master first and then cherry picking the changes we'd like to release onto the release branches, @hdgarrood ?
removeUnique :: Eq a => Ord a => [a] -> [a] | ||
removeUnique = concat . filter twoOrMore . group . sort | ||
where | ||
twoOrMore :: [a] -> Bool |
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 still think this can just be (\x -> length x > 1)
, but I'll leave that to your judgement.
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.
Going with the "guaranteed fast" over the "likely fast" strategy, even if it's a few more lines of code.
Yes please - there may not be another 0.13.x release, but even if we do make an 0.13.9 release we will want any changes in master first. @milesfrain I like the If you'd like to rewrite the
If you'd like to do |
I edited the above comment a few times, sorry. I'm done now :) |
d478394
to
32ad517
Compare
Rebased to master.
I'll make a separate PR to clean-up ordering code that includes:
|
Looks like CI is failing because a compiler warning has changed. Could you run the tests with —accept to see if that fixes it? |
What command is that? |
|
Since preserving all duplicates is not the core focus of this PR, I just removed that change and left a note about it to be tackled in another issue. Some tests still needed to be modified to account for minor reordering of warnings though. I assume that's because the list is actually sorted with this change. |
Yeah, I think having the same warnings in a different order is fine. Thanks very much! Also, from earlier,
Yes, that sounds like a good idea to me. |
See the "Reducing incremental rebuild time with large file dependency" thread for context.
Looks like the issue is here:
purescript/src/Language/PureScript/Sugar/Names/Common.hs
Line 27 in c044d69
Profiling shows warnDuplicateRefs takes 46% of the build time - the majority of it spent making 96 million calls to ==.
I replaced the slow
\\ nub
pattern with a fasteronlyDuplicates
function. I'm surprised this doesn't exist already in some library.The
onlyDuplicates
function also seems more correct than\\ nub
in that it doesn't arbitrarily discard one of every duplicate. For example:For my use case with a large
Tailwind.purs
file, overall compilation times are reduced from 3.1 to 1.2 seconds and the share of time spent inwarnDuplicateRefs
is reduced from 46% to 0.5%.Here are more detailed performance notes:
Original
This PR