Netty 4: Channel-EventLoop mapping in the NioEventLoopGroup

356 views
Skip to first unread message

Tobber Harley

unread,
Mar 21, 2014, 11:06:10 AM3/21/14
to ne...@googlegroups.com

We have a distributed application that uses Netty (4) for our low level communication stuff. A process in that system execute multiple tasks. Each task contains a set of input and output channels. Channels are permanently assigned to a single EventLoop in Netty. The mapping of Channel to EventLoop happens in round robin fashion in the (Nio)EventLoopGroup. We would like to have more control over this mapping and assign all channels of the same task to the same EventLoop(s). The purpose for this "Channel-EventLoop affinity" is to reduce lock-contention for some specific memory management stuff in the ChannelHandlers. We looked in Netty documentation, but didn´t find anything. Is there a general way to do that in Netty 4?

Another possibility I identified would be to overwrite the "EventExecutor next()" method in the "MultithreadEventExecutorGroup" that implements the round robin channel mapping (I think so at least). Is that a possible way to enforce a different mapping, or do I create undesirable side effects with this hack?

I am grateful for any help!! Tobi

Jakob Buchgraber

unread,
Mar 21, 2014, 3:48:53 PM3/21/14
to ne...@googlegroups.com
Hi Tobi,

there is currently no way to plug in in your own algorithm, however I believe this is something that's planned for the Netty 5 release.

You are right in that the MultithreadEventExecutorGroup.next() method is responsible for assigning channels to event loops. You can hack there and there shouldn't be any undesirable side effects. I am not too familiar with the netty 4 codebase, but I believe you'll want to overload the next method to next(Channel ch) and pass it the channel when register: https://github.com/netty/netty/blob/4.0/transport/src/main/java/io/netty/channel/MultithreadEventLoopGroup.java#L68 is called.

PS: Better wait for Trustin or Normain to confirm that :).

Norman Maurer

unread,
Mar 22, 2014, 4:34:53 AM3/22/14
to ne...@googlegroups.com, Jakob Buchgraber
Everything right with what Jakob said ;)

We may even have this fixed as part of GSOC
-- 
Norman Maurer

JBoss, by Red Hat

--

---
You received this message because you are subscribed to the Google Groups "Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netty+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tobber Harley

unread,
Mar 24, 2014, 8:11:53 AM3/24/14
to ne...@googlegroups.com, Jakob Buchgraber
Hey guys,

Many thanks for the answer!!

Cheers,
Tobi
Reply all
Reply to author
Forward
0 new messages