grpc-java icon indicating copy to clipboard operation
grpc-java copied to clipboard

Any plans to add KQueue to default channelType and EventLoopGroup?

Open ktdilsiz opened this issue 3 years ago • 3 comments

Any plans to add KQueue in the default detection here: https://github.com/grpc/grpc-java/blob/master/netty/src/main/java/io/grpc/netty/Utils.java#L113-L133

Thanks

ktdilsiz avatar Jul 12 '22 22:07 ktdilsiz

Why are you interested?

ejona86 avatar Jul 14 '22 16:07 ejona86

We have a product where we use this and we have Linux/Epoll on our clusters and we have Macs to work on. Hence it helps with easier local testing on unix domain socket. We can currently put our own "if" conditions to achieve it but we were hoping to simplify the code.

From

if (Epoll.isAvailable()){
        ServerBuilder serverBuilder = NettyServerBuilder
                .forAddress(domainSocketAddress)
                .channelType(EpollServerDomainSocketChannel.class)
                .workerEventLoopGroup(new EpollEventLoopGroup())
                .bossEventLoopGroup(new EpollEventLoopGroup());
} else if (KQueue.isAvailable()){
        ServerBuilder serverBuilder = NettyServerBuilder
                .forAddress(domainSocketAddress)
                .channelType(KqueueServerDomainSocketChannel.class)
                .workerEventLoopGroup(new KqueueEventLoopGroup())
                .bossEventLoopGroup(new KqueueEventLoopGroup());
}

to

ServerBuilder serverBuilder = NettyServerBuilder
                .forAddress(domainSocketAddress);

ktdilsiz avatar Jul 14 '22 18:07 ktdilsiz

I know for Epoll you couldn't simplify things because you must specify EpollServerDomainSocketChannel and if you specify that you need to specify the worker/boss. That issue is really a mundane Netty issue and wouldn't be that hard to resolve with a new channel type that supports inet and unix.

On client-side we have UdsNameResolver and UdsNettyChannelProvider such that you can use unix: targets when creating a channel and have it use epoll. That could be taught to use kqueue as well and then we'd probably need grpc-netty-shaded to include the kqueue binaries. But that's client-side and not server-side.

I think for you to get what you need you'd really need the Netty API to be fixed so there is a channel type that handles both inet and unix.

ejona86 avatar Jul 14 '22 19:07 ejona86

Looks like the main things here are really for Netty. gRPC's done about as much as it can do right now. Annoying, but also the state of things.

ejona86 avatar Sep 27 '22 21:09 ejona86