-
Notifications
You must be signed in to change notification settings - Fork 66
Stream and Pipe benchmarks #1300
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
base: main
Are you sure you want to change the base?
Conversation
…marks for filter, map, and combined
Results run a 2021 Macbook Pro, M1, 64gb
|
import kyo.bench.BaseBench | ||
import org.openjdk.jmh.annotations.* | ||
|
||
class StreamPipeBench extends BaseBench: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the arena
package is for comparative benchmarks, this new one should be under the bench
package directly
Does it mean that the abstraction to share code has a minimal overhead? The better performance with Var can be just an artifact of how the code ends up JIT compiled since handles specialize execution |
Yeah I think the two main take-aways are: (1) in general I'm going to experiment with some others, but I think the approach in this PR is my preferred way to deduplicate the code in |
Addresses concerns raised in #1166 (see discussion here)
Problem
Pipe
currently reimplements a bunch of the same functionality asStream
in a slightly different way. We need to figure out whether to maintain parallel implementations (in which case we would probably try to abstract the tests to a single reusable suite), haveStream
usePipe
for its transformation method implementations, find some other way to reuse code between the two types, or rethinkPipe
entirely.What choice we make will depend largely on performance.
Solution
This PR (not meant to be merged in its current form) has some benchmarks for basic stream transformations on both
Stream
andPipe
(map
,mapPure
,filter
, andfilterPure
). Results running locally on a macbook pro are posted below.It also includes a POC attempt to abstract the common logic from
Stream
andPipe
methods. Both types essentially do the same thing, but one usesArrowEffect.handleLoop
and the other just usesLoop
+Poll.andMap
. I've added aStreamTransformations
object that includeshandleMap
,handleMapPure
,handleFilter
, andhandleFilterPure
which can be used withinArrowEffect.handleLoop
orLoop
/Poll.andMap
to provide a common implementation."Abstract" versions of filter and pure methods are included in the benchmark to see how abstracting the logic affects performance.
Notes