-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Issues/3340 single buffer #3364
Issues/3340 single buffer #3364
Conversation
based off of SizeBoundReplayBuffer, but with simplifications in size/cpacity/replay etc.
add bindings to places where the SingletonReplayBuffer can be used in stead of the SizeBoundReplayBuffer
to compare against the replaced implementation
@MikkelHJuul Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
1 similar comment
@MikkelHJuul Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@MikkelHJuul Thank you for signing the Contributor License Agreement! |
@OlegDokuka - you answered my issue ticket, so I'll pull you in here :) Are there anything specific wrt. testing you require or want before being able to review? Edit: I will run with coverage to check if the current tests cover the code, at latest Monday |
I have run the tests with coverage. Mostly fine (about the same coverage as SizeBound). I added some tests (parameterizations) There is a bug in Fusion that makes the replay(1) cache only "fuse" the first element. I suspect something with replayFused vs. poll not working correctly |
When the same value is passed two times in a row the prior implementation does not convey the second signal
with ae5153e the performance of the SingletonBuffer is reduced; and it's about 18% more performant than the SizeBoundReplayBuffer. The memory usage is about halved (not counting the leaked reference) |
FUSED still not working
benchmarks/src/main/java/reactor/core/publisher/SinkManyReplayLatestBenchmark.java
Outdated
Show resolved
Hide resolved
benchmarks/src/main/java/reactor/core/publisher/SinkManyReplayLatestBenchmark.java
Outdated
Show resolved
Hide resolved
reactor-core/src/main/java/reactor/core/publisher/FluxReplay.java
Outdated
Show resolved
Hide resolved
@MikkelHJuul do you mind adding a JCStress test as well. If you don't have time I can do a followup PR |
Absolutely, also, seeing as the leak was easily fixed in my other PR (I was too hellbent on reducing the memory footprint) I think it is a must have to verify better performance, and also to verify memory footprint before accepting this implementation.
|
I have written a JCStress test can you validate that it actually tests anything of value |
after thinking about this some more, I cannot fully see how subscription-buffer protects vs. high write (but I cannot see how this is done in the original solution; which in fact does a non-atomic volatile reassignment in its also should the
I wrote a jcstress with both cases and got:
which is close - Do-While-non-blocking write has a slightly higher affinity, but fewer fully correct results. I ran the same test on the
my code for these tests is present in the branch https://github.com/MikkelHJuul/reactor-core/tree/issues/3340-single-processor-stresstest |
@MikkelHJuul Did you have any success mitigating the concurrency issue when using |
Sorry I didn't reply. The API between the wrapping class and the cache implementation is simply not that good for concurrent calling as far as I remember. The single implementation was "safe" for concurrent calling but cache calling to downstream subscribers could trigger incorrect behavior (skipped emission to a subscriber) |
This implements part of the Issue, and thus replaces the SizeBoundReplayBuffer in cases where only a single historical record is required. (replay latest, limit 1, all 1(, cache 1?))
Apart from fixing the memory-issue in this single
Sinks.Many
implementation (as described in the Issue ticket #3340), I will noted a sizable performance-increase:33% better single-threaded performance, and about 100% better performance for the higher number of threads. see gist.
I'm not entirely strong on the
Fusable
-interface, so please read those lines carefully! (mostly a copy-paste of theSizeBoundReplayBuffer
)I may take longer to refactor the remaining SizeBoundReplayBuffer to use
AtomicReferenceArray
. in order to fix the issue for the remaining cases.