Commit 9f9e768a authored by Dominik Charousset's avatar Dominik Charousset

Fix quantum adjustment for batches

parent eb4a6823
...@@ -56,6 +56,9 @@ public: ...@@ -56,6 +56,9 @@ public:
/// Stores slot IDs for sender (hdl) and receiver (self). /// Stores slot IDs for sender (hdl) and receiver (self).
stream_slots slots; stream_slots slots;
/// Stores the last computed desired batch size.
int32_t desired_batch_size;
/// Amount of credit we have signaled upstream. /// Amount of credit we have signaled upstream.
int32_t assigned_credit; int32_t assigned_credit;
......
...@@ -94,10 +94,8 @@ public: ...@@ -94,10 +94,8 @@ public:
static bool enabled(const nested_queue_type& q) noexcept; static bool enabled(const nested_queue_type& q) noexcept;
static inline deficit_type quantum(const nested_queue_type&, static deficit_type quantum(const nested_queue_type& q,
deficit_type x) noexcept { deficit_type x) noexcept;
return x;
}
// -- constructors, destructors, and assignment operators -------------------- // -- constructors, destructors, and assignment operators --------------------
......
...@@ -62,6 +62,12 @@ bool downstream_messages::enabled(const nested_queue_type& q) noexcept { ...@@ -62,6 +62,12 @@ bool downstream_messages::enabled(const nested_queue_type& q) noexcept {
return !congested; return !congested;
} }
auto downstream_messages::quantum(const nested_queue_type& q,
deficit_type x) noexcept -> deficit_type {
// TODO: adjust quantum based on the stream priority
return x * q.policy().handler->desired_batch_size;
}
} // namespace policy } // namespace policy
} // namespace caf } // namespace caf
...@@ -61,6 +61,7 @@ inbound_path::inbound_path(stream_manager_ptr mgr_ptr, stream_slots id, ...@@ -61,6 +61,7 @@ inbound_path::inbound_path(stream_manager_ptr mgr_ptr, stream_slots id,
: mgr(std::move(mgr_ptr)), : mgr(std::move(mgr_ptr)),
hdl(std::move(ptr)), hdl(std::move(ptr)),
slots(id), slots(id),
desired_batch_size(initial_credit),
assigned_credit(0), assigned_credit(0),
prio(stream_priority::normal), prio(stream_priority::normal),
last_acked_batch_id(0), last_acked_batch_id(0),
...@@ -89,7 +90,6 @@ void inbound_path::handle(downstream_msg::batch& x) { ...@@ -89,7 +90,6 @@ void inbound_path::handle(downstream_msg::batch& x) {
void inbound_path::emit_ack_open(local_actor* self, actor_addr rebind_from) { void inbound_path::emit_ack_open(local_actor* self, actor_addr rebind_from) {
CAF_LOG_TRACE(CAF_ARG(slots) << CAF_ARG(rebind_from)); CAF_LOG_TRACE(CAF_ARG(slots) << CAF_ARG(rebind_from));
assigned_credit = initial_credit; assigned_credit = initial_credit;
int32_t desired_batch_size = initial_credit;
unsafe_send_as(self, hdl, unsafe_send_as(self, hdl,
make<upstream_msg::ack_open>( make<upstream_msg::ack_open>(
slots.invert(), self->address(), std::move(rebind_from), slots.invert(), self->address(), std::move(rebind_from),
...@@ -108,7 +108,7 @@ void inbound_path::emit_ack_batch(local_actor* self, long queued_items, ...@@ -108,7 +108,7 @@ void inbound_path::emit_ack_batch(local_actor* self, long queued_items,
auto credit = std::max((x.max_throughput * 2) auto credit = std::max((x.max_throughput * 2)
- (assigned_credit + queued_items), - (assigned_credit + queued_items),
0l); 0l);
auto batch_size = static_cast<int32_t>(x.items_per_batch); desired_batch_size = static_cast<int32_t>(x.items_per_batch);
if (credit != 0) if (credit != 0)
assigned_credit += credit; assigned_credit += credit;
CAF_LOG_DEBUG(CAF_ARG(credit) << CAF_ARG(batch_size)); CAF_LOG_DEBUG(CAF_ARG(credit) << CAF_ARG(batch_size));
...@@ -116,7 +116,8 @@ void inbound_path::emit_ack_batch(local_actor* self, long queued_items, ...@@ -116,7 +116,8 @@ void inbound_path::emit_ack_batch(local_actor* self, long queued_items,
make<upstream_msg::ack_batch>(slots.invert(), make<upstream_msg::ack_batch>(slots.invert(),
self->address(), self->address(),
static_cast<int32_t>(credit), static_cast<int32_t>(credit),
batch_size, last_batch_id)); desired_batch_size,
last_batch_id));
last_acked_batch_id = last_batch_id; last_acked_batch_id = last_batch_id;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment