Commit b6a31c78 authored by Dominik Charousset's avatar Dominik Charousset

Fix credit calculation

parent 43cac8bd
...@@ -115,11 +115,10 @@ void inbound_path::emit_ack_batch(local_actor* self, int32_t queued_items, ...@@ -115,11 +115,10 @@ void inbound_path::emit_ack_batch(local_actor* self, int32_t queued_items,
timespan cycle, timespan complexity) { timespan cycle, timespan complexity) {
CAF_LOG_TRACE(CAF_ARG(slots) << CAF_ARG(queued_items) << CAF_ARG(cycle) CAF_LOG_TRACE(CAF_ARG(slots) << CAF_ARG(queued_items) << CAF_ARG(cycle)
<< CAF_ARG(complexity)); << CAF_ARG(complexity));
CAF_IGNORE_UNUSED(queued_items);
auto x = stats.calculate(cycle, complexity); auto x = stats.calculate(cycle, complexity);
// Hand out enough credit to fill our queue for 2 cycles. // Hand out enough credit to fill our queue for 2 cycles.
auto credit = std::max((x.max_throughput * 2) auto credit = std::max((x.max_throughput * 2) - assigned_credit, 0);
- (assigned_credit + queued_items),
0);
// Protect against overflow on `assigned_credit`. // Protect against overflow on `assigned_credit`.
auto max_new_credit = std::numeric_limits<int32_t>::max() - assigned_credit; auto max_new_credit = std::numeric_limits<int32_t>::max() - assigned_credit;
// The manager can restrict or adjust the amount of credit. // The manager can restrict or adjust the amount of credit.
......
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