Class TransportConfig

java.lang.Object
express.mvp.myra.transport.TransportConfig

public final class TransportConfig extends Object
Configuration for transport creation and runtime behavior.

This immutable configuration object controls all aspects of transport initialization, including backend selection, buffer pool sizing, and performance tuning parameters.

Configuration Options

Transport Configuration Parameters
ParameterDefaultDescription
backendTypeIO_URINGI/O backend implementation
numBuffers256Number of registered buffers
bufferSize64KBSize of each buffer
connectionTimeout5sTCP connection timeout
sqPollEnabledfalseEnable SQPOLL kernel thread

SQPOLL Mode

When sqPollEnabled is true, io_uring creates a dedicated kernel thread that polls for submissions, eliminating syscall overhead entirely for steady-state I/O. This provides the lowest latency but consumes a CPU core continuously.

CPU Affinity

For latency-sensitive applications, use cpuAffinity to pin the I/O thread and sqPollCpuAffinity to pin the SQPOLL kernel thread. Values of -1 disable affinity (OS scheduler chooses).

Usage Example

TransportConfig config = TransportConfig.builder()
    .backendType(BackendType.IO_URING)
    .registeredBuffers(RegisteredBuffersConfig.builder()
        .numBuffers(512)
        .bufferSize(32768)
        .build())
    .connectionTimeout(Duration.ofSeconds(10))
    .sqPollEnabled(true)
    .sqPollCpuAffinity(3)
    .build();

Transport transport = TransportFactory.create(config);
\n *\n * @see TransportFactory\n * @see Transport\n
  • Method Details

    • builder

      public static TransportConfig.Builder builder()
      Creates a new builder for constructing configuration.
      Returns:
      a new builder with default values
    • backendType

      public TransportConfig.BackendType backendType()
      Returns the selected I/O backend type.
      Returns:
      the backend type (never null)
    • registeredBuffersConfig

      public TransportConfig.RegisteredBuffersConfig registeredBuffersConfig()
      Returns the registered buffer pool configuration.
      Returns:
      the buffer configuration (never null)
    • connectionTimeout

      public Duration connectionTimeout()
      Returns the TCP connection timeout.
      Returns:
      the connection timeout duration
    • cpuAffinity

      public int cpuAffinity()
      Returns the CPU affinity for the I/O thread.
      Returns:
      the CPU core ID, or -1 if no affinity is set
    • sqPollCpuAffinity

      public int sqPollCpuAffinity()
      Returns the CPU affinity for the SQPOLL kernel thread.

      Only relevant when sqPollEnabled() is true.

      Returns:
      the CPU core ID, or -1 if no affinity is set
    • sqPollEnabled

      public boolean sqPollEnabled()
      Returns whether SQPOLL mode is enabled.

      When enabled, io_uring creates a dedicated kernel thread that continuously polls for submissions, eliminating syscall overhead.\n *\n * @return true if SQPOLL is enabled\n

    • sqPollIdleTimeout

      public int sqPollIdleTimeout()
      Returns the SQPOLL idle timeout in milliseconds.

      After this duration with no submissions, the kernel thread enters a sleep state to reduce CPU usage during idle periods.

      Returns:
      the idle timeout in milliseconds