Skip to content
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

Fix performance regression in bufferSliding #1217

Merged
merged 2 commits into from Jul 23, 2020

Conversation

Avasil
Copy link
Collaborator

@Avasil Avasil commented Jul 22, 2020

I also updated to Scala 2.13.3 - sorry for the noise

2.12:

Benchmark                                         (chunkCount)  (chunkSize)   Mode  Cnt   Score   Error  Units
ChunkedEvalFilterMapSumBenchmark.monixObservable          1000         1000  thrpt   20  66.211 ± 2.483  ops/s

2.13, before the change:

Benchmark                                         (chunkCount)  (chunkSize)   Mode  Cnt   Score   Error  Units
ChunkedEvalFilterMapSumBenchmark.monixObservable          1000         1000  thrpt   20  35.212 ± 3.410  ops/s (2.13 before)

2.13, after the change:

Benchmark                                         (chunkCount)  (chunkSize)   Mode  Cnt   Score   Error  Units
ChunkedEvalFilterMapSumBenchmark.monixObservable          1000         1000  thrpt   20  72.209 ± 3.425  ops/s (2.13 after)

@@ -31,5 +31,8 @@ object compat {
def hasDefiniteSize[X](i: IterableOnce[X]): Boolean = i.knownSize >= 0

def newBuilder[From, A, C](bf: BuildFrom[From, A, C], from: From): mutable.Builder[A, C] = bf.newBuilder(from)

@inline def toSeq[A](array: Array[AnyRef]): Seq[A] =
new scala.collection.immutable.ArraySeq.ofRef(array).asInstanceOf[Seq[A]]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the change

Copy link
Member

Choose a reason for hiding this comment

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

It will be hard to keep track of these internal helpers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Any ideas? Alternatively, it could be placed in reactive (it has only one usage) but it would be even more scattered then.
I have put it in private [monix] in case we can delete it one day.

Initially I wanted to point to the same ArraySeq but mutable one doesn't perform well in my benchmarks. It seems like toSeq is quite expensive there.

Copy link
Member

Choose a reason for hiding this comment

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

That's fine.

Copy link
Member

Choose a reason for hiding this comment

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

We'll have to remember we have it I guess.

@Avasil
Copy link
Collaborator Author

Avasil commented Jul 22, 2020

I'm running benchmarks again and the results are all over the place, I'll rerun it over the night with Slack/Chrome/etc. closed

@Avasil
Copy link
Collaborator Author

Avasil commented Jul 22, 2020

I've run it more times and it seems to be OK:

2.13 this PR:
[info] Benchmark                                         (chunkCount)  (chunkSize)   Mode  Cnt   Score   Error  Units
[info] ChunkedEvalFilterMapSumBenchmark.monixObservable          1000         1000  thrpt   30  77.968 ± 3.677  ops/s


2.13 master:
[info] Benchmark                                         (chunkCount)  (chunkSize)   Mode  Cnt   Score   Error  Units
[info] ChunkedEvalFilterMapSumBenchmark.monixObservable          1000         1000  thrpt   30  53.559 ± 0.364  ops/s

2.12:
[info] Benchmark                                         (chunkCount)  (chunkSize)   Mode  Cnt   Score   Error  Units
[info] ChunkedEvalFilterMapSumBenchmark.monixObservable          1000         1000  thrpt   30  65.132 ± 1.613  ops/s

Still a lot of variance in some results between runs but there's consistent trend that it might be even slightly faster on Scala 2.13 now

@alexandru
Copy link
Member

I think that's fine. You would help me if you merged this, given your 2.13 upgrade 🙂

@Avasil Avasil merged commit 6678f6e into monix:master Jul 23, 2020
1 check passed
@Avasil Avasil added this to the 3.3.0 milestone Sep 13, 2020
@Avasil Avasil deleted the fix-buffer-sliding-regression branch November 14, 2020 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants