Skip to content

Epoll: Don't wake event loop when splicing#9354

Merged
normanmaurer merged 1 commit intonetty:4.1from
njhill:splicequeue
Jul 12, 2019
Merged

Epoll: Don't wake event loop when splicing#9354
normanmaurer merged 1 commit intonetty:4.1from
njhill:splicequeue

Conversation

@njhill
Copy link
Copy Markdown
Member

@njhill njhill commented Jul 11, 2019

Motivation

I noticed this while looking at something else. AbstractEpollStreamChannel::spliceQueue is an MPSC queue but only accessed from the event loop. So it could be just changed to e.g. an ArrayDeque. This PR instead reverts to using is as an MPSC queue to avoid dispatching a task to the EL, as appears was the original intention.

Modification

Change AbstractEpollStreamChannel::spliceQueue to be volatile and lazily initialized via double-checked locking. Add tasks directly to the queue from the public methods rather than possibly waking the EL just to enqueue.

An alternative would be to change PlatformDependent.newMpscQueue() to new ArrayDeque() and be done with it :)

Result

Less disruptive channel/fd-splicing.

Motivation

I noticed this while looking at something else.
AbstractEpollStreamChannel::spliceQueue is an MPSC queue but only
accessed from the event loop. So it could be just changed to e.g. an
ArrayDeque. This PR instead reverts to using is as an MPSC queue to
avoid dispatching a task to the EL, as appears was the original
intention.

Modification

Change AbstractEpollStreamChannel::spliceQueue to be volatile and lazily
initialized via double-checked locking. Add tasks directly to the queue
from the public methods rather than possibly waking the EL just to
enqueue.

An alternative is just to change PlatformDependent.newMpscQueue() to new
ArrayDeque() and be done with it :)

Result

Less disruptive channel/fd-splicing.
@netty-bot
Copy link
Copy Markdown

Can one of the admins verify this patch?

@normanmaurer
Copy link
Copy Markdown
Member

@netty-bot test this please

@normanmaurer
Copy link
Copy Markdown
Member

@njhill thanks this looks great!

@normanmaurer normanmaurer added this to the 4.1.38.Final milestone Jul 12, 2019
@normanmaurer normanmaurer self-assigned this Jul 12, 2019
@normanmaurer normanmaurer merged commit 5384bbc into netty:4.1 Jul 12, 2019
normanmaurer pushed a commit that referenced this pull request Jul 12, 2019
Motivation

I noticed this while looking at something else.
AbstractEpollStreamChannel::spliceQueue is an MPSC queue but only
accessed from the event loop. So it could be just changed to e.g. an
ArrayDeque. This PR instead reverts to using is as an MPSC queue to
avoid dispatching a task to the EL, as appears was the original
intention.

Modification

Change AbstractEpollStreamChannel::spliceQueue to be volatile and lazily
initialized via double-checked locking. Add tasks directly to the queue
from the public methods rather than possibly waking the EL just to
enqueue.

An alternative is just to change PlatformDependent.newMpscQueue() to new
ArrayDeque() and be done with it :)

Result

Less disruptive channel/fd-splicing.
@njhill njhill deleted the splicequeue branch July 12, 2019 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants