softwaremill / ox

Safe direct style concurrency and resiliency for Scala on the JVM

Home Page:https://ox.softwaremill.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Optimize Chunk

kciesielski opened this issue · comments

Chunk is now just a thin wrapper for an Array. It should be optimized to avoid unnecessary copying of data. Operations like concatenation,drop, take, splitAt etc. should be reimplemented. Such approach has been taken by libs like fs2 and zio, as well as Pekko's ByteString. All these libraries use their representations to represent a byte array with performance optimizations, to keep good efficiency in stream processing.
ZIO: https://github.com/zio/zio/blob/76a463192ef27c5f1ccc038cf93fe35b42ad4869/core/shared/src/main/scala/zio/Chunk.scala
fs2: https://github.com/typelevel/fs2/blob/main/core/shared/src/main/scala/fs2/Chunk.scala
Pekko: https://github.com/apache/pekko/blob/d98942dd3b021874ac324464f3fd788f9be046df/actor/src/main/scala-2.13/org/apache/pekko/util/ByteString.scala