Skip to content

Commit

Permalink
Optimizes unnecessary select iterations.
Browse files Browse the repository at this point in the history
When the application already knows about the executables in the queue, we don't
need select to terminate with EINTR. We either ran the executable and the queue
is empty (in which case we want select to sleep), or we know the queue is not
empty and thus will run select with a timeout of 0.
  • Loading branch information
balazsracz committed Feb 3, 2024
1 parent a386fcc commit 1999aef
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/executor/Executor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,13 @@ void ExecutorBase::wait_with_select(long long wait_length)
fd_set fd_r(selectRead_);
fd_set fd_w(selectWrite_);
fd_set fd_x(selectExcept_);
if (!empty()) {
// We will check the queue for any prior wakeups after this call. If we
// already processed the executables, the wakeup is not necessary. Without
// this clear, there would always be two select() iterations happening when
// we are done with work and can go to sleep.
selectHelper_.clear_wakeup();
if (!empty())
{
wait_length = 0;
}
long long max_sleep = MSEC_TO_NSEC(config_executor_max_sleep_msec());
Expand Down

0 comments on commit 1999aef

Please sign in to comment.