-
Notifications
You must be signed in to change notification settings - Fork 248
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
StreamEx.ofTree: rewrite with custom spliterator #17
Comments
Benchmarks show that new implementation is indeed better Stream source in all tests is: StreamEx.ofTree("", s -> s.length() == depth ? null : Stream.of("a", "b", "c").map(s::concat)); count = .count(), has = .has("a") (find the second element in the stream), hasNone = .has("foo") (find non-existing element). Quasi means that
Short-circuiting ops indeed become short-circuiting. All times are better except Also stack traces for non-short-circuit operations in 0.6.2 contain 2 frames less per tree depth. Short-circuiting operations have constant stack depth. Current implementation refuses to parallelize at all. 0.6.1 implementation could parallelize the top level of the tree. It would be nice to preserve this level of parallelization in 0.6.2 as well. |
It was discovered that if mapper function contains an intermediate operation and does not have explicit Here's benchmark results for depth 5,7,9: Parallel:
Sequential:
Here new implementation is better for every test, both for time and memory consumption, both for parallel and sequential. Also stream closure issues seem to be solved. Thus the feature is considered to be complete. |
Currently
StreamEx.ofTree
implementation isflatMap
-based and inherits all theflatMap
issues: poor short-circuiting and buffering when external iteration used. It's possible to write custom spliterator which would be free of these disadvantages and probably could split better.The text was updated successfully, but these errors were encountered: