Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Prefer ownersIterator #10713

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

Draft
wants to merge 1 commit into
base: 2.13.x
Choose a base branch
from
Draft

Conversation

som-snytt
Copy link
Contributor

When using ownerChain to search, prefer ownersIterator to creating and discarding a list.

A find may not even examine all owners.

@scala-jenkins scala-jenkins added this to the 2.13.15 milestone Mar 14, 2024
@SethTisue SethTisue added the internal not resulting in user-visible changes (build changes, tests, internal cleanups) label Mar 14, 2024
@som-snytt
Copy link
Contributor Author

It would be nice to demonstrate actual benefit.

It would be nice if it could be automated. Possibly "eliminate intermediate collection" is just "insert .view", except ownerChain is not a standard operation.

It's nice that the lint in 2.13.13 works (if backticks are removed):

[warn] .../scala/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala:134:22: Name bSym is already introduced in an enclosing scope as value bSym at line 81. Did you intend to match it using backquoted `bSym`?
[warn]                 case bSym => false
[warn]                      ^

@som-snytt som-snytt marked this pull request as ready for review April 11, 2024 14:21
@som-snytt
Copy link
Contributor Author

Noticed an ancient commit for this change, so it's a forever issue. Maybe the API should be LazyList, or it really needs hasTransOwnerWhere.

Copy link
Member

@SethTisue SethTisue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems mergeable to me. tinkering carries a slight risk, and any performance improvement would likely be smaller than measuring error, but historically we have tended to merge such small speed improvements as long as they don't degrade code quality

@som-snytt
Copy link
Contributor Author

People hate "intermediate collections" so much more than either "advanced" or "elementary" ones.

@SethTisue SethTisue modified the milestones: 2.13.15, 2.13.16 Aug 14, 2024
@som-snytt
Copy link
Contributor Author

I'm still at the "these are just numbers" stage, but I rediscovered the compiler-benchmark project and had enough wits to try

hot -psource=scalap

as suggested.

[info] Benchmark                                   (corpusPath)  (corpusVersion)  (extraArgs)  (resident)  (scalaVersion)  (source)    Mode  Cnt     Score    Error  Units
[info] HotScalacBenchmark.compile                                         latest                    false         2.13.14    scalap  sample  538   584.587 ± 13.469  ms/op
[info] HotScalacBenchmark.compile:compile·p0.00                           latest                    false         2.13.14    scalap  sample        548.405           ms/op
[info] HotScalacBenchmark.compile:compile·p0.50                           latest                    false         2.13.14    scalap  sample        578.814           ms/op
[info] HotScalacBenchmark.compile:compile·p0.90                           latest                    false         2.13.14    scalap  sample        599.785           ms/op
[info] HotScalacBenchmark.compile:compile·p0.95                           latest                    false         2.13.14    scalap  sample        612.473           ms/op
[info] HotScalacBenchmark.compile:compile·p0.99                           latest                    false         2.13.14    scalap  sample        625.591           ms/op
[info] HotScalacBenchmark.compile:compile·p0.999                          latest                    false         2.13.14    scalap  sample       2709.520           ms/op
[info] HotScalacBenchmark.compile:compile·p0.9999                         latest                    false         2.13.14    scalap  sample       2709.520           ms/op
[info] HotScalacBenchmark.compile:compile·p1.00                           latest                    false         2.13.14    scalap  sample       2709.520           ms/op
[success] Total time: 635 s (10:35), completed Aug 22, 2024, 11:30:22 AM

[info] Benchmark                                   (corpusPath)  (corpusVersion)  (extraArgs)  (resident)                (scalaVersion)  (source)    Mode  Cnt    Score   Error  Units
[info] HotScalacBenchmark.compile                                         latest                    false  2.13.15-bin-8eb5619-SNAPSHOT    scalap  sample  512  600.816 ± 4.862  ms/op
[info] HotScalacBenchmark.compile:compile·p0.00                           latest                    false  2.13.15-bin-8eb5619-SNAPSHOT    scalap  sample       555.745          ms/op
[info] HotScalacBenchmark.compile:compile·p0.50                           latest                    false  2.13.15-bin-8eb5619-SNAPSHOT    scalap  sample       593.494          ms/op
[info] HotScalacBenchmark.compile:compile·p0.90                           latest                    false  2.13.15-bin-8eb5619-SNAPSHOT    scalap  sample       627.782          ms/op
[info] HotScalacBenchmark.compile:compile·p0.95                           latest                    false  2.13.15-bin-8eb5619-SNAPSHOT    scalap  sample       642.463          ms/op
[info] HotScalacBenchmark.compile:compile·p0.99                           latest                    false  2.13.15-bin-8eb5619-SNAPSHOT    scalap  sample       728.446          ms/op
[info] HotScalacBenchmark.compile:compile·p0.999                          latest                    false  2.13.15-bin-8eb5619-SNAPSHOT    scalap  sample       967.836          ms/op
[info] HotScalacBenchmark.compile:compile·p0.9999                         latest                    false  2.13.15-bin-8eb5619-SNAPSHOT    scalap  sample       967.836          ms/op
[info] HotScalacBenchmark.compile:compile·p1.00                           latest                    false  2.13.15-bin-8eb5619-SNAPSHOT    scalap  sample       967.836          ms/op
[success] Total time: 629 s (10:29), completed Aug 22, 2024, 12:08:26 PM

2.13.14 drops from 625 to 2700, this PR from 728 to 967. I don't know what the scores mean yet. I don't know if that is better than not knowing the number.

@Ichoran
Copy link
Contributor

Ichoran commented Aug 22, 2024

Is this the only thing that's changed since .14? Otherwise, you really should compare before/after this PR alone.

The count isn't high enough to know whether the 2700 vs 970 number is real--that corresponds to the slowest sample in every case. Otherwise, the whole histogram seems to show .14 as faster.

@som-snytt
Copy link
Contributor Author

[info] Do not assume the numbers tell you what you want them to tell.
[info] Benchmark                                   (corpusPath)  (corpusVersion)  (extraArgs)  (resident)                (scalaVersion)  (source)    Mode  Cnt    Score   Error  Units
[info] HotScalacBenchmark.compile                                         latest                    false  2.13.15-bin-52b2013-SNAPSHOT    scalap  sample  506  611.198 ± 4.475  ms/op
[info] HotScalacBenchmark.compile:compile·p0.00                           latest                    false  2.13.15-bin-52b2013-SNAPSHOT    scalap  sample       580.911          ms/op
[info] HotScalacBenchmark.compile:compile·p0.50                           latest                    false  2.13.15-bin-52b2013-SNAPSHOT    scalap  sample       603.980          ms/op
[info] HotScalacBenchmark.compile:compile·p0.90                           latest                    false  2.13.15-bin-52b2013-SNAPSHOT    scalap  sample       633.340          ms/op
[info] HotScalacBenchmark.compile:compile·p0.95                           latest                    false  2.13.15-bin-52b2013-SNAPSHOT    scalap  sample       651.847          ms/op
[info] HotScalacBenchmark.compile:compile·p0.99                           latest                    false  2.13.15-bin-52b2013-SNAPSHOT    scalap  sample       723.444          ms/op
[info] HotScalacBenchmark.compile:compile·p0.999                          latest                    false  2.13.15-bin-52b2013-SNAPSHOT    scalap  sample       925.893          ms/op
[info] HotScalacBenchmark.compile:compile·p0.9999                         latest                    false  2.13.15-bin-52b2013-SNAPSHOT    scalap  sample       925.893          ms/op
[info] HotScalacBenchmark.compile:compile·p1.00                           latest                    false  2.13.15-bin-52b2013-SNAPSHOT    scalap  sample       925.893          ms/op
[success] Total time: 642 s (10:42), completed Aug 22, 2024, 4:38:22 PM


[info] Benchmark                                   (corpusPath)  (corpusVersion)  (extraArgs)  (resident)                (scalaVersion)  (source)    Mode  Cnt    Score   Error  Units
[info] HotScalacBenchmark.compile                                         latest                    false  2.13.15-bin-8eb5619-SNAPSHOT    scalap  sample  503  620.134 ± 4.588  ms/op
[info] HotScalacBenchmark.compile:compile·p0.00                           latest                    false  2.13.15-bin-8eb5619-SNAPSHOT    scalap  sample       583.008          ms/op
[info] HotScalacBenchmark.compile:compile·p0.50                           latest                    false  2.13.15-bin-8eb5619-SNAPSHOT    scalap  sample       612.368          ms/op
[info] HotScalacBenchmark.compile:compile·p0.90                           latest                    false  2.13.15-bin-8eb5619-SNAPSHOT    scalap  sample       654.311          ms/op
[info] HotScalacBenchmark.compile:compile·p0.95                           latest                    false  2.13.15-bin-8eb5619-SNAPSHOT    scalap  sample       674.444          ms/op
[info] HotScalacBenchmark.compile:compile·p0.99                           latest                    false  2.13.15-bin-8eb5619-SNAPSHOT    scalap  sample       777.792          ms/op
[info] HotScalacBenchmark.compile:compile·p0.999                          latest                    false  2.13.15-bin-8eb5619-SNAPSHOT    scalap  sample       827.326          ms/op
[info] HotScalacBenchmark.compile:compile·p0.9999                         latest                    false  2.13.15-bin-8eb5619-SNAPSHOT    scalap  sample       827.326          ms/op
[info] HotScalacBenchmark.compile:compile·p1.00                           latest                    false  2.13.15-bin-8eb5619-SNAPSHOT    scalap  sample       827.326          ms/op
[success] Total time: 633 s (10:33), completed Aug 22, 2024, 4:58:11 PM

still just numbers. But worth adding, these are optimized local builds.

More to the point, I'd like my local workflow to always include benchmarking (with history to consult).

@Ichoran
Copy link
Contributor

Ichoran commented Aug 23, 2024

Hm, second one seems like it might be a little slower for real. But it's so close that I wouldn't believe it unless you go back and forth a couple times.

@lrytz

This comment was marked as off-topic.

@lrytz
Copy link
Member

lrytz commented Aug 23, 2024

i was trying to reproduce, do you have patches for compiler-benchmark to make things work? the repo seems a bit outdated.

@som-snytt
Copy link
Contributor Author

I commented out old dotty refs and updated Scala to 2.13.14 but nothing else. (Hence my first run with vanilla 2.13.14.) Otherwise, I just set the compiler version and ran with it. I hope to return to it later. I remember several years ago, I failed to get reliable results on my fancy box at work running Ubuntu natively. Now I'm running under WSL, so I don't know if there are architectural limitations.

@som-snytt som-snytt marked this pull request as draft August 26, 2024 21:28
@som-snytt
Copy link
Contributor Author

Not quite closing yet, but converting to draft until I have some time to pursue proper benchmarking.

The PR itself is just a moral statement about style.

If retronym didn't notice anything in 2017, why should I play diesalbla now?

@som-snytt som-snytt closed this Sep 11, 2024
@SethTisue SethTisue removed this from the 2.13.16 milestone Sep 11, 2024
@som-snytt som-snytt reopened this Nov 9, 2024
@scala-jenkins scala-jenkins added this to the 2.13.16 milestone Nov 9, 2024
@SethTisue SethTisue modified the milestones: 2.13.16, 2.13.17 Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal not resulting in user-visible changes (build changes, tests, internal cleanups)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants