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

Performance improvements in Chunk#toArray #979

Merged
merged 1 commit into from
Nov 18, 2017

Conversation

mpilquist
Copy link
Member

@mpilquist mpilquist commented Nov 18, 2017

Fixes #977.

Includes a series of optimizations:

  • Chunk#toArray now simply uses a while loop instead of using the segment machinery to access each element (not sure why it ever did what it was doing...)
  • toArray is overridden on each array backed chunk subtype using .slice operation
  • toByteBuffer was added to Chunk.Bytes allowing a zero-copy view of the underlying array

@fiadliel could you take a look at this?

@fiadliel
Copy link
Contributor

The specialized toArray was the same as what I had, and other changes look great! Throughput for the sync NIO calls is now amongst the fastest options; async is slower, but I think reasonably acceptable:

[info] Benchmark                                              Mode  Cnt  Score   Error  Units
[info] LargeStreamBenchmark.commonsIo                         avgt   10  3.467 ± 0.276   s/op
[info] LargeStreamBenchmark.fs2IoStream                       avgt   10  6.050 ± 0.268   s/op
[info] LargeStreamBenchmark.fs2NioAsyncStream                 avgt   10  7.764 ± 0.237   s/op
[info] LargeStreamBenchmark.fs2NioStream                      avgt   10  2.969 ± 0.102   s/op
[info] LargeStreamBenchmark.monixObservable                   avgt   10  4.307 ± 0.161   s/op
[info] LargeStreamBenchmark.monixObservableWithAsyncBoundary  avgt   10  2.833 ± 0.153   s/op

@mpilquist mpilquist merged commit b09e0c3 into typelevel:series/0.10 Nov 18, 2017
@mpilquist
Copy link
Member Author

Awesome, thanks for benchmarking!

@mpilquist mpilquist deleted the topic/toArray branch November 27, 2017 12:41
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.

2 participants