-
Notifications
You must be signed in to change notification settings - Fork 603
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
fix: chunk get together when random rechunk #3205
base: main
Are you sure you want to change the base?
Conversation
@@ -2413,7 +2413,7 @@ final class Stream[+F[_], +O] private[fs2] (private[fs2] val underlying: Pull[F, | |||
Pull.output(acc) >> go(hd, size, tl) | |||
else { | |||
val (out, rem) = acc.splitAt(size - 1) | |||
Pull.output(out) >> go(rem ++ hd, -1, tl) | |||
Pull.output(out) >> go(rem, -1, Pull.output(hd) >> tl) |
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.
Is Pull.output(hd) >> tl
equivalent to s
?
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.
Yes. I should change it to s
. :) Thanks for that.
@@ -2413,7 +2413,7 @@ final class Stream[+F[_], +O] private[fs2] (private[fs2] val underlying: Pull[F, | |||
Pull.output(acc) >> go(hd, size, tl) |
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.
I think this is another error. The size
should ideally be the desired size of the next output chunk, but that is the one being emited in acc
. Instead should be -1, so that the next iteration recomputes a new size based on the first chunk of tl
.
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.
Yes! I realize it now.
Uh, it seems that it will lead the time to be longer and fail the pipeline. :( |
test("rechunkRandomly sometimes emits everything in a single chunk") { | ||
val fiveChunks = Stream(1) ++ Stream(2) ++ Stream(3) ++ Stream(4) ++ Stream(5) | ||
|
||
val source = fiveChunks.rechunkRandomlyWithSeed(0.1, 2.0)(5).chunks.toList |
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.
Also the way factor
and nextSize
are implemented now, I don't think factor
can ever reach maxFactor
. So for this example nextSize
can only be 0 or 1.
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.
Yeah, that's true. Now the range is [minFactor, maxFactor).
I can replicate the CI failures locally, can you replicate them as well? Not sure what's wrong, could it be getting into some sort of loop or something?
|
Thanks! I replicated it locally but didn't discover the details. I should check it carefully. :) |
This wants to fix #3195
Consider the case: if (size < acc.size)
The code will continue to append the 'hd' to 'rem', which may be larger than the 'size', to the next 'go' method.
And this will lead to the 'tl' being consumed totally without restricting the size of 'Chunk'.
:)