Alternative Java Selector Implementations

I'm writing a high performance/low garbage application (microseconds matter) that has a networking component. One of the sore points that I've come across is the implementation of the built in Selector for Java NIO.

A few things that are problematic:

  • Lots of object creation. Pretty much every call to selectedKeys() creates a lot of objects. Iterators, boxing/unboxing, you name it. Not a problem with most other cases but the application I'm writing needs to create as little garbage as possible.
  • Layers upon layers of locking and synchronization. At the time the selectorImpls were built, a bunch of the Java lock primitives didn't exist. As a result it's clunky and not optimal. In my use case, there's only one thread calling select so the locking is in fact useless.
  • Extending or changing the selector implementation is a nonstarter. Most of the classes are final, with private and package-private members located in the sun.nio.ch.* package. Native methods also complicate things.

Are there any other more modern implementations of the selector that may be more performant?

The networking libraries I've examined just use the built in Java selector under the covers. Any help would be appreciated.

Replies

Login or Register to answer


Meta
Questions
813920
Answered
813920
Users
813920