Commit c483fe4f authored by Juho Snellman's avatar Juho Snellman

Make benchmark more deterministic

- Depending on the exact execution order of timers with same
  expiration time, the exact results would depend on whether the
  "close" timer was the first or second of those two.
- Do a two phase close; first time around just go to a draining
  mode. Then after all activity has been drained, delete the
  object properly.
- Also gives us a more diverse event mix, since it currently
  might not have quite enough medium length timers that actually
  get executed.
parent cbe1c82a
...@@ -66,7 +66,17 @@ public: ...@@ -66,7 +66,17 @@ public:
} }
void on_close() { void on_close() {
if (closing_) {
delete this; delete this;
} else {
// First time the timeout triggers, we just put the
// object into a closing state where it'll start winding down
// work. Then we forcibly close it a bit later. We do it like
// this to remove any non-determinism between the execution order
// of the close timer and the pace timer.
closing_ = true;
timers_->schedule(&close_timer_, 10*1000*50);
}
} }
void on_pace() { void on_pace() {
if (tx_count_) { if (tx_count_) {
...@@ -78,8 +88,10 @@ public: ...@@ -78,8 +88,10 @@ public:
delete this; delete this;
} }
void on_request() { void on_request() {
if (!closing_) {
other_->transmit(100); other_->transmit(100);
} }
}
void unidle() { void unidle() {
if (allow_schedule_in_range) { if (allow_schedule_in_range) {
...@@ -106,6 +118,7 @@ private: ...@@ -106,6 +118,7 @@ private:
int pace_quota_ = 1; int pace_quota_ = 1;
int pace_interval_ticks_ = 10; int pace_interval_ticks_ = 10;
int request_interval_ = 100; int request_interval_ = 100;
bool closing_ = false;
}; };
int Unit::id_counter_ = 0; int Unit::id_counter_ = 0;
......
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