Skip to content

Port: Restore configurable ioRatio-based task scheduling in SingleThreadIoEventLoop (#17481) - #17603

Merged
normanmaurer merged 1 commit into
5.0from
io5
Sep 25, 2026
Merged

normanmaurer merged 1 commit into
5.0from
io5

Conversation

@normanmaurer

Copy link
Copy Markdown
Member

Motivation:

The unification done in #13991/#14557 replaced the per-transport ioRatio
scheduling with a fixed maxTaskProcessingQuantumMs cap on task
processing
before returning to IO. Under sustained load the task queue is never
empty, so the event loop can spend up to the full quantum on tasks every
iteration regardless of how little time was just spent on IO, delaying
IO servicing (and so response completion) for a minority of requests.
This was observed as an elevated mean (but not median) round-trip
latency after upgrading from 4.1 to 4.2, which went away on rollback.

Modifications:

  • Add back a volatile ioRatio field and functional getIoRatio()/
    setIoRatio(int) on SingleThreadIoEventLoop, configurable via the new
    io.netty.eventLoop.ioRatio system property (default 100, which
    preserves the current fixed-quantum behaviour unchanged).
  • When ioRatio < 100, size each iteration's task budget as
    ioTime * (100 - ioRatio) / ioRatio, capped by
    maxTaskProcessingQuantumNs, matching the pre-4.2 NioEventLoop formula
    while keeping the existing quantum as a safety upper bound.
  • Add setter / getter to MultiThreadIoEventLoopGroup so it is supported
    globally

Result:

Users hitting the 4.2 scheduling regression can restore proportional
IO/task balancing with a single setIoRatio(50) call (or the new system
property), with no change in behaviour for anyone who doesn't opt in.

…ventLoop (#17481)

Motivation:

The unification done in #13991/#14557 replaced the per-transport ioRatio
scheduling with a fixed maxTaskProcessingQuantumMs cap on task
processing
before returning to IO. Under sustained load the task queue is never
empty, so the event loop can spend up to the full quantum on tasks every
iteration regardless of how little time was just spent on IO, delaying
IO servicing (and so response completion) for a minority of requests.
This was observed as an elevated mean (but not median) round-trip
latency after upgrading from 4.1 to 4.2, which went away on rollback.

Modifications:

- Add back a volatile ioRatio field and functional getIoRatio()/
  setIoRatio(int) on SingleThreadIoEventLoop, configurable via the new
  io.netty.eventLoop.ioRatio system property (default 100, which
  preserves the current fixed-quantum behaviour unchanged).
- When ioRatio < 100, size each iteration's task budget as
  ioTime * (100 - ioRatio) / ioRatio, capped by
  maxTaskProcessingQuantumNs, matching the pre-4.2 NioEventLoop formula
  while keeping the existing quantum as a safety upper bound.
- Add setter / getter to MultiThreadIoEventLoopGroup so it is supported
globally

Result:

Users hitting the 4.2 scheduling regression can restore proportional
IO/task balancing with a single setIoRatio(50) call (or the new system
property), with no change in behaviour for anyone who doesn't opt in.
@normanmaurer normanmaurer changed the title Restore configurable ioRatio-based task scheduling in SingleThreadIoEventLoop (#17481) Port: Restore configurable ioRatio-based task scheduling in SingleThreadIoEventLoop (#17481) Sep 23, 2026
@normanmaurer normanmaurer added this to the 5.0.0.Final milestone Sep 23, 2026
@testlens-app

testlens-app Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

🚨 TestLens detected 1 failed test 🚨

Here is what you can do:

  1. Inspect the test failures carefully.
  2. If you are convinced that some of the tests are flaky, you can mute them below.
  3. Finally, trigger a rerun by checking the rerun checkbox.

Test Summary

Build PR / linux-x86_64-java25 build > Netty/Common

Test Runs Flakiness
SingleThreadEventExecutorTest > testSuspendDoesNotRaceWithCancelledScheduledTask() ❌ 25% 🔴

🏷️ Commit: 8367fd3
▶️ Tests: 186856 executed
⚪️ Checks: 12/12 completed

Test Failures

SingleThreadEventExecutorTest > testSuspendDoesNotRaceWithCancelledScheduledTask() (Netty/Common in Build PR / linux-x86_64-java25 build)
org.opentest4j.AssertionFailedError: worker thread did not terminate at iteration 1497 ==> expected: <false> but was: <true>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertFalse.failNotFalse(AssertFalse.java:63)
	at org.junit.jupiter.api.AssertFalse.assertFalse(AssertFalse.java:36)
	at org.junit.jupiter.api.Assertions.assertFalse(Assertions.java:239)
	at io.netty.util.concurrent.SingleThreadEventExecutorTest.testSuspendDoesNotRaceWithCancelledScheduledTask(SingleThreadEventExecutorTest.java:243)
	at java.base/java.lang.reflect.Method.invoke(Method.java:565)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
expected actual
false true

Rerun Controls

Select tests to mute in this pull request:

  • SingleThreadEventExecutorTest > testSuspendDoesNotRaceWithCancelledScheduledTask()

Reuse successful test results:

  • ♻️ Only rerun the tests that failed or were muted before

Click the checkbox to trigger a rerun:

  • Rerun jobs

Learn more about TestLens at testlens.app/docs.

@normanmaurer
normanmaurer merged commit 5e9389c into 5.0 Sep 25, 2026
12 of 13 checks passed
@normanmaurer
normanmaurer deleted the io5 branch September 25, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant