Skip to content
Snippets Groups Projects
Commit 1e3f06d8 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

cbus: use a more reliable test to check whether we need a syscall

Check ev_async_pending() rather than state of the pipe to find
out whether we need a syscall. On a simple read-only test pipe->pipe
is empty while there is already a pending event more than a few times a
millisecond.

At the same time, checking ev_async_pending() is more expensive, since
it's an atomic variable, but overall performance increased
after the patch, so the cost seems to be justified.
parent 855d0067
No related branches found
No related tags found
No related merge requests found
......@@ -169,7 +169,7 @@ cbus_flush_cb(ev_loop * /* loop */, struct ev_async *watcher,
bool peer_output_was_empty = STAILQ_EMPTY(&peer->output);
cbus_lock(pipe->bus);
pipe_was_empty = STAILQ_EMPTY(&pipe->pipe);
pipe_was_empty = !ev_async_pending(&pipe->fetch_output);
/** Flush input */
STAILQ_CONCAT(&pipe->pipe, &pipe->input);
/*
......@@ -201,7 +201,7 @@ cpipe_peek_impl(struct cpipe *pipe)
cbus_lock(pipe->bus);
STAILQ_CONCAT(&pipe->output, &pipe->pipe);
if (! STAILQ_EMPTY(&peer->input)) {
peer_pipe_was_empty = STAILQ_EMPTY(&peer->pipe);
peer_pipe_was_empty = !ev_async_pending(&peer->fetch_output);
STAILQ_CONCAT(&peer->pipe, &peer->input);
}
cbus_unlock(pipe->bus);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment