Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
dwijnand merged 1 commit intoscala:2.13.xfromKisaragiEffective:t12499
Mar 2, 2023

Conversation

@KisaragiEffective
Copy link
Contributor

@KisaragiEffectiveKisaragiEffective commentedJan 7, 2023
edited by SethTisue
Loading

by switching the pattern matcher to usemutable.LinkedHashSet instead ofListSet

fixesscala/bug#12499

@scala-jenkinsscala-jenkins added this to the2.13.11 milestoneJan 7, 2023
@lrytz
Copy link
Member

This seems to non-deterministically failpartest test/files/neg/t7020.scala. I assume it's about the undefined Set iteration order.

@KisaragiEffective
Copy link
ContributorAuthor

I feel the same, passed/failed on local randomly. Which should I do to fix it?

  1. modify patmat's logic to fix t7020 -- This would make large diff and takes longer time.
  2. update t7020 errors and leave patmat's logic as is -- I don't think it will resolve the issue.
  3. usejava.util.LinkedHashSet and leave t7020 as is --LinkedHashSet is not immutable since it's from Java. Would it cause an issue?
  4. backport part of Add SeqSet and SetFromMap implementations scala-library-next#35 to use, and leave t7020 as is

@dwijnand
Copy link
Member

@KisaragiEffective I don't mind if we switch to java.util.LinkedHashSet.

@KisaragiEffective
Copy link
ContributorAuthor

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))
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

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.

dwijnand reacted with thumbs up emoji
@SethTisue
Copy link
Member

@KisaragiEffective interested in returning to this...?

@KisaragiEffective
Copy link
ContributorAuthor

It's still failed on t7020. Are there other implicit assumptions?

@lrytz
Copy link
Member

The current version still callstoSet, which creates an immutable HashSet. See my comment here:#10258 (comment)

@KisaragiEffectiveKisaragiEffective marked this pull request as ready for reviewFebruary 21, 2023 06:44
@KisaragiEffective
Copy link
ContributorAuthor

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>
@KisaragiEffectiveKisaragiEffective changed the titleexperiment fix for SI-12499 (patmat perf)Patmat: Switch from ListSet to mutable.LinkedHashSet (SI-12499)Mar 2, 2023
@KisaragiEffective
Copy link
ContributorAuthor

(changed title according to squashed commit)

dwijnand reacted with heart emoji

@dwijnanddwijnand merged commit5ecdcf8 intoscala:2.13.xMar 2, 2023
@SethTisueSethTisue changed the titlePatmat: Switch from ListSet to mutable.LinkedHashSet (SI-12499)Fix pathologically slow compilation of some pattern matches since 2.13.7Mar 2, 2023
@michelou
Copy link

@SethTisue IMO the issue is only partially fixed; seemy comment inflix/flix PR 4916.

@SethTisue
Copy link
Member

@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
Copy link
ContributorAuthor

Seems this is not enough for solve problem, seeflix/flix#4916 (comment)

@SethTisue
Copy link
Member

I see — new ticket, if you're able to minimize it?

@KisaragiEffective
Copy link
ContributorAuthor

I've already filed (however not sure if it's root cause of the perf regression)scala/bug#12760

@KisaragiEffectiveKisaragiEffective deleted the t12499 branchJanuary 11, 2025 15:22
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@lrytzlrytzlrytz left review comments

@dwijnanddwijnanddwijnand approved these changes

Assignees

@dwijnanddwijnand

Labels

release-notesworth highlighting in next release notes

Projects

None yet

Milestone

2.13.11

Development

Successfully merging this pull request may close these issues.

Patmat phase 60 times slower with 2.13.6, 2.13.7

6 participants

@KisaragiEffective@lrytz@dwijnand@SethTisue@michelou@scala-jenkins

[8]ページ先頭

©2009-2025 Movatter.jp