- Notifications
You must be signed in to change notification settings - Fork3.1k
Fix pathologically slow compilation of some pattern matches since 2.13.7#10258
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
lrytz commentedJan 9, 2023
This seems to non-deterministically fail |
KisaragiEffective commentedJan 9, 2023
I feel the same, passed/failed on local randomly. Which should I do to fix it?
|
dwijnand commentedJan 19, 2023
@KisaragiEffective I don't mind if we switch to java.util.LinkedHashSet. |
KisaragiEffective commentedJan 22, 2023
I'm not sure why it was failed... |
| defcreate(ps:Iterable[Prop])= psmatch { | ||
| caseps:Set[Prop]=>newAnd(ps) | ||
| case _=>newAnd(ps.to(scala.collection.immutable.ListSet)) | ||
| case _=>newAnd(new java.util.LinkedHashSet[Prop](ps.toSet.asJava).asScala.to(Set)) |
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.
ps.toSet creates an immutable HashSet which has non-deterministic iteration order.
I think we can use Scala'smutable.LinkedHashSet instead of Java's. Maybe the best option is to change theAnd andOr case classes to have amutable.LinkedHashSet[Prop] parameter? That would express the fact that an ordered collection is required.
Otherwise, usecollection.Set[Prop]?
@dwijnand what do you think?
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.
Isn'tjava.util.LinkedHashSet known to be faster thanmutable.LinkedHashSet? Good catch on the toSet: we need to build up the set in insertion-order of the iterable.
I don't mind if we change the parameter either.
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.
The Java version is possibly still faster, but our LinkedHashSet was recently brought up to date (#10221). Compared to ListSet which we are replacing here, it's likely going to be fine.
SethTisue commentedFeb 17, 2023
@KisaragiEffective interested in returning to this...? |
KisaragiEffective commentedFeb 18, 2023
It's still failed on t7020. Are there other implicit assumptions? |
lrytz commentedFeb 20, 2023
The current version still calls |
KisaragiEffective commentedFeb 21, 2023
they're green exceptcombined step 🎉 |
* experiment fix for SI-12499 (patmat perf)* use java.util.LinkedHashSet* switch j.u to s.c.m LinkedHashSet* avoid convert to Set to keep deterministic iteration order* fix compile errorCo-authored-by: Dale Wijnand <dale.wijnand@gmail.com>
KisaragiEffective commentedMar 2, 2023
(changed title according to squashed commit) |
michelou commentedMar 6, 2023
@SethTisue IMO the issue is only partially fixed; seemy comment in |
SethTisue commentedMar 6, 2023
@michelou ah, sorry to hear that. I wonder if what you're experiencing now has some entirely different cause, or if it's more that the PR we have needs a followup adjustment. |
KisaragiEffective commentedMar 27, 2023
Seems this is not enough for solve problem, seeflix/flix#4916 (comment) |
SethTisue commentedMar 27, 2023
I see — new ticket, if you're able to minimize it? |
KisaragiEffective commentedMar 27, 2023
I've already filed (however not sure if it's root cause of the perf regression)scala/bug#12760 |
Uh oh!
There was an error while loading.Please reload this page.
by switching the pattern matcher to use
mutable.LinkedHashSetinstead ofListSetfixesscala/bug#12499