mpsc_queue: allow interrupting try_consume_batch#1104
mpsc_queue: allow interrupting try_consume_batch#1104lukaszstolarczuk merged 1 commit intopmem:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1104 +/- ##
==========================================
+ Coverage 94.14% 94.24% +0.09%
==========================================
Files 51 51
Lines 5227 5247 +20
==========================================
+ Hits 4921 4945 +24
+ Misses 306 302 -4
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
lukaszstolarczuk
left a comment
There was a problem hiding this comment.
Reviewed 3 of 5 files at r1.
Reviewable status: 3 of 5 files reviewed, 4 unresolved discussions (waiting on @igchor and @karczex)
include/libpmemobj++/experimental/mpsc_queue.hpp, line 83 at r1 (raw file):
pmem_log_type *pmem; static constexpr size_t consume_invalid =
what exactly these vars are storing...?
tests/CMakeLists.txt, line 973 at r1 (raw file):
build_test(mpsc_queue_consume_interrupt mpsc_queue/consume_interrupt.cpp) add_test_generic(NAME mpsc_queue_consume_interrupt SCRIPT mpsc_queue/mpsc_queue_consume_interrupt_0.cmake TRACERS none memcheck pmemcheck)
_0 in script's name is redundant, I believe
tests/mpsc_queue/consume_interrupt.cpp, line 5 at r1 (raw file):
/* * basic.pp -- Single threaded tests for
wrong name and description 😉
tests/mpsc_queue/consume_interrupt.cpp, line 17 at r1 (raw file):
#include <libpmemobj++/make_persistent.hpp> #include <libpmemobj++/persistent_ptr.hpp> #include <libpmemobj++/string_view.hpp>
it seems redundant
b424d97 to
a615b52
Compare
igchor
left a comment
There was a problem hiding this comment.
Reviewable status: 3 of 5 files reviewed, 4 unresolved discussions (waiting on @karczex and @lukaszstolarczuk)
include/libpmemobj++/experimental/mpsc_queue.hpp, line 83 at r1 (raw file):
Previously, lukaszstolarczuk (Łukasz Stolarczuk) wrote…
what exactly these vars are storing...?
Done.
tests/CMakeLists.txt, line 973 at r1 (raw file):
Previously, lukaszstolarczuk (Łukasz Stolarczuk) wrote…
_0in script's name is redundant, I believe
Done.
tests/mpsc_queue/consume_interrupt.cpp, line 5 at r1 (raw file):
Previously, lukaszstolarczuk (Łukasz Stolarczuk) wrote…
wrong name and description 😉
Done.
tests/mpsc_queue/consume_interrupt.cpp, line 17 at r1 (raw file):
Previously, lukaszstolarczuk (Łukasz Stolarczuk) wrote…
it seems redundant
Done.
a615b52 to
7cb14ca
Compare
lukaszstolarczuk
left a comment
There was a problem hiding this comment.
Reviewed 4 of 4 files at r2.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @igchor and @karczex)
include/libpmemobj++/experimental/mpsc_queue.hpp, line 87 at r2 (raw file):
/* Stores offset and length of next message to be consumed. If * The values are set to `consume_invalid` next message must be
the values (lowercase)
and what exactly did you mean by "if the values are set"?
include/libpmemobj++/experimental/mpsc_queue.hpp, line 88 at r2 (raw file):
/* Stores offset and length of next message to be consumed. If * The values are set to `consume_invalid` next message must be * obtained from ringbug_consume. */
this ringbuf is bugged 😉 (ringbug)
tests/mpsc_queue/consume_interrupt.cpp, line 49 at r2 (raw file):
UT_ASSERT(!ret); /* XXX: this is to make sure that try_consume_batch later in the
why is this an XXX ?
igchor
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @karczex and @lukaszstolarczuk)
include/libpmemobj++/experimental/mpsc_queue.hpp, line 87 at r2 (raw file):
Previously, lukaszstolarczuk (Łukasz Stolarczuk) wrote…
the values(lowercase)and what exactly did you mean by "if the values are set"?
I mean if someone sets them to consume_invalid ;d I'm not sure how to reprehase it
include/libpmemobj++/experimental/mpsc_queue.hpp, line 88 at r2 (raw file):
Previously, lukaszstolarczuk (Łukasz Stolarczuk) wrote…
this ringbuf is bugged 😉 (
ringbug)
Done.
tests/mpsc_queue/consume_interrupt.cpp, line 49 at r2 (raw file):
Previously, lukaszstolarczuk (Łukasz Stolarczuk) wrote…
why is this an XXX ?
Because we want to eventually hide the wraparound behind the iterators. So try_consume_batch will call the callback only once.
7cb14ca to
de6c200
Compare
karczex
left a comment
There was a problem hiding this comment.
Reviewable status: 4 of 5 files reviewed, 4 unresolved discussions (waiting on @igchor and @lukaszstolarczuk)
include/libpmemobj++/experimental/mpsc_queue.hpp, line 286 at r3 (raw file):
* try_consume_batch failed. In that case, call f() with the * same offset/len as before. */ if (consume_offset == consume_invalid) {
Wouldn't be better to add to ringbuff_t varialble which track state of the consume (as may be only one consumer, the change would be trivial)
bool consume_pending;
which you set at the beginning of ringbuf_consume and reset at the end of ringbuf_release.
And early return 0 from ringbuf_consume if previous one is pending.
So instead of this comparison to consume_invalid, you may check
if(ring_buffer->consume_pending)
de6c200 to
68aedfc
Compare
igchor
left a comment
There was a problem hiding this comment.
Reviewable status: 3 of 6 files reviewed, 4 unresolved discussions (waiting on @karczex and @lukaszstolarczuk)
include/libpmemobj++/experimental/mpsc_queue.hpp, line 286 at r3 (raw file):
Previously, karczex (Paweł Karczewski) wrote…
Wouldn't be better to add to ringbuff_t varialble which track state of the consume (as may be only one consumer, the change would be trivial)
bool consume_pending;which you set at the beginning of ringbuf_consume and reset at the end of ringbuf_release.
And early return 0 from ringbuf_consume if previous one is pending.So instead of this comparison to consume_invalid, you may check
if(ring_buffer->consume_pending)
Done.
karczex
left a comment
There was a problem hiding this comment.
Reviewable status: 3 of 6 files reviewed, 3 unresolved discussions (waiting on @lukaszstolarczuk)
lukaszstolarczuk
left a comment
There was a problem hiding this comment.
Reviewed 3 of 3 files at r4.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @igchor)
If interrupt (exception) happens, next try_consume_batch will resume from the previous position.
68aedfc to
1f4030c
Compare
lukaszstolarczuk
left a comment
There was a problem hiding this comment.
Reviewed 1 of 1 files at r5.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @igchor)
If interrupt (exception) happens, next try_consume_batch will
resume from the previous position.
This change is