optimize ZStream.fromIteratorSucceed #8254
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR here're benchmark results
New version is several times faster and puts less pressure on GC.
Here's the benchmark. I can add it to MR, but I'm not sure where to add it.
zio.StreamBenchmarks?The original intention was to optimize
ZStream.apply, since it unexpectedly works quite slow for seemingly harmless convenience method. And sinceZStream.applyrelies onZStream.fromIteratorSucceed, this MR changes the latter one.I know that in real world these changes will be most likely unnoticeable, but IMO it still worth merging. I've found because I was comparing performance of ZIO Streams to Akka streams and fs2, and was surprised by how slow ZIO Streams were, until it was was found that this particular method was causing degradation.