Home / Function/ scheduleWriteMultiple() — netty Function Reference

scheduleWriteMultiple() — netty Function Reference

Architecture documentation for the scheduleWriteMultiple() function in IoUringSocketChannel.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  9471c8f5_5044_ecfc_8b01_05388745f842["scheduleWriteMultiple()"]
  e27b80ce_bfb2_8300_cc64_6e66bd077b74["IoUringSocketUnsafe"]
  9471c8f5_5044_ecfc_8b01_05388745f842 -->|defined in| e27b80ce_bfb2_8300_cc64_6e66bd077b74
  0541f6f7_9dc8_a4dc_7c1b_35f3cba0416f["scheduleWriteSingle()"]
  9471c8f5_5044_ecfc_8b01_05388745f842 -->|calls| 0541f6f7_9dc8_a4dc_7c1b_35f3cba0416f
  style 9471c8f5_5044_ecfc_8b01_05388745f842 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUringSocketChannel.java lines 108–159

        @Override
        protected int scheduleWriteMultiple(ChannelOutboundBuffer in) {
            assert writeId == 0;

            IoUringSocketChannelConfig ioUringSocketChannelConfig = (IoUringSocketChannelConfig) config();
            //at least one buffer in the batch exceeds `IO_URING_WRITE_ZERO_COPY_THRESHOLD`.
            if (IoUring.isSendmsgZcSupported()
                    && (ioUringSocketChannelConfig.shouldWriteZeroCopy(((ByteBuf) in.current()).readableBytes()))) {
                IoUringIoHandler handler = registration().attachment();

                IovArray iovArray = handler.iovArray();
                int offset = iovArray.count();
                // Limit to the maximum number of fragments to ensure we don't get an error when we have too many
                // buffers.
                iovArray.maxCount(Native.MAX_SKB_FRAGS);
                try {
                    in.forEachFlushedMessage(new ChannelOutboundBuffer.MessageProcessor() {
                        @Override
                        public boolean processMessage(Object msg) throws Exception {
                            if (msg instanceof ByteBuf) {
                                ByteBuf buf = (ByteBuf) msg;
                                int length = buf.readableBytes();
                                if (ioUringSocketChannelConfig.shouldWriteZeroCopy(length)) {
                                    return iovArray.processMessage(msg);
                                }
                            }
                            return false;
                        }
                    });
                } catch (Exception e) {
                    // This should never happen, anyway fallback to single write.
                    return scheduleWriteSingle(in.current());
                }
                long iovArrayAddress = iovArray.memoryAddress(offset);
                int iovArrayLength = iovArray.count() - offset;

                MsgHdrMemoryArray msgHdrArray = handler.msgHdrMemoryArray();
                MsgHdrMemory hdr = msgHdrArray.nextHdr();
                assert hdr != null;
                hdr.set(iovArrayAddress, iovArrayLength);
                IoUringIoOps ops = IoUringIoOps.newSendmsgZc(fd().intValue(), (byte) 0, 0, hdr.address(), nextOpsId());
                byte opCode = ops.opcode();
                writeId = registration().submit(ops);
                writeOpCode = opCode;
                if (writeId == 0) {
                    return 0;
                }
                return 1;
            }
            // Should not use sendmsg_zc, just use normal writev.
            return super.scheduleWriteMultiple(in);
        }

Domain

Subdomains

Frequently Asked Questions

What does scheduleWriteMultiple() do?
scheduleWriteMultiple() is a function in the netty codebase, defined in transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUringSocketChannel.java.
Where is scheduleWriteMultiple() defined?
scheduleWriteMultiple() is defined in transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUringSocketChannel.java at line 108.
What does scheduleWriteMultiple() call?
scheduleWriteMultiple() calls 1 function(s): scheduleWriteSingle.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free