Skip to content

Commit 668dcbf

Browse files
committed
Remove LIFO scheduler as Thread::yield during VT submission is a no-op
1 parent c1556c2 commit 668dcbf

7 files changed

Lines changed: 11 additions & 377 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ At a high level:
77
- Each Netty event loop is backed by a virtual thread (the "event loop virtual thread").
88
- Each such virtual thread is executed on a dedicated carrier platform thread.
99
- Virtual threads created from the event-loop-specific ThreadFactory returned by the group will be associated with the same EventLoopScheduler and, when possible, will run on the same carrier platform thread as the event loop.
10-
- You can select FIFO or LIFO scheduling when constructing the group by passing `EventLoopSchedulerType` (default is FIFO).
10+
- You can select FIFO scheduling when constructing the group by passing `EventLoopSchedulerType` (default is FIFO).
1111

1212
This allows code that must block (for example, blocking I/O or synchronous library calls) to be executed without moving work between unrelated threads, reducing wake-ups and improving cache locality compared to offloading to an external thread pool.
1313

1414
## Key behavior (user-facing)
15-
- Create a `VirtualMultithreadIoEventLoopGroup` like any other Netty `EventLoopGroup`. It behaves like a `MultiThreadIoEventLoopGroup` from the Netty API, but the event loops are driven by virtual threads and coordinated with carrier platform threads by a per-event-loop `EventLoopScheduler` (FIFO or LIFO).
15+
- Create a `VirtualMultithreadIoEventLoopGroup` like any other Netty `EventLoopGroup`. It behaves like a `MultiThreadIoEventLoopGroup` from the Netty API, but the event loops are driven by virtual threads and coordinated with carrier platform threads by a per-event-loop `EventLoopScheduler` (FIFO).
1616
- Call `group.vThreadFactory()` to obtain a `ThreadFactory` that creates virtual threads tied to an `EventLoopScheduler` of the group. When those virtual threads block, the scheduler parks them and resumes them later using the carrier thread.
1717
- Virtual threads created via the group's `vThreadFactory()` will attempt to inherit the scheduler and run with low-overhead handoffs back to the event loop when continuing work.
1818
- Virtual threads created with `Thread.ofVirtual().factory()` (the JVM default factory) do NOT automatically inherit the group's scheduler.

benchmark-runner/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ All configuration is via environment variables:
6666
| `SERVER_THREADS` | 2 | Number of event loop threads |
6767
| `SERVER_REACTIVE` | false | Use reactive handler with Reactor |
6868
| `SERVER_USE_CUSTOM_SCHEDULER` | false | Use custom Netty scheduler |
69-
| `SERVER_SCHEDULER_TYPE` | fifo | Scheduler type: fifo or lifo |
7069
| `SERVER_IO` | epoll | I/O type: epoll, nio, or io_uring |
7170
| `SERVER_NO_TIMEOUT` | false | Disable HTTP client timeout |
7271
| `SERVER_TASKSET` | 2,3 | CPU affinity (e.g., "2-5") |
@@ -277,7 +276,6 @@ java \
277276
--mock-url http://localhost:8080/fruits \
278277
--threads 2 \
279278
--use-custom-scheduler true \
280-
--scheduler-type fifo \
281279
--io epoll
282280
```
283281

benchmark-runner/scripts/run-benchmark.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ MOCK_TASKSET="${MOCK_TASKSET:-4,5}" # CPUs for mock server
3131
SERVER_PORT="${SERVER_PORT:-8081}"
3232
SERVER_THREADS="${SERVER_THREADS:-2}"
3333
SERVER_USE_CUSTOM_SCHEDULER="${SERVER_USE_CUSTOM_SCHEDULER:-false}"
34-
SERVER_SCHEDULER_TYPE="${SERVER_SCHEDULER_TYPE:-fifo}"
3534
SERVER_IO="${SERVER_IO:-epoll}"
3635
SERVER_TASKSET="${SERVER_TASKSET:-2,3}" # CPUs for handoff server
3736
SERVER_JVM_ARGS="${SERVER_JVM_ARGS:-}"
@@ -52,7 +51,7 @@ LOAD_GEN_URL="${LOAD_GEN_URL:-http://localhost:8081/fruits}"
5251
WARMUP_DURATION="${WARMUP_DURATION:-10s}"
5352
TOTAL_DURATION="${TOTAL_DURATION:-30s}"
5453
MIN_STEADY_STATE_SECONDS=20
55-
PROFILING_DELAY_SECONDS="${PROFILING_DELAY_SECONDS:-5}"
54+
PROFILING_DELAY_SECONDS="${PROFILING_DELAY_SECONDS:-10}"
5655
PROFILING_DURATION_SECONDS="${PROFILING_DURATION_SECONDS:-10}"
5756

5857
# Profiling configuration
@@ -409,7 +408,6 @@ start_handoff_server() {
409408
--mock-url http://localhost:$MOCK_PORT/fruits \
410409
--threads $SERVER_THREADS \
411410
--use-custom-scheduler $SERVER_USE_CUSTOM_SCHEDULER \
412-
--scheduler-type $SERVER_SCHEDULER_TYPE \
413411
--io $SERVER_IO \
414412
--no-timeout $SERVER_NO_TIMEOUT \
415413
--reactive $SERVER_REACTIVE \
@@ -704,7 +702,6 @@ print_config() {
704702
log " Threads: $SERVER_THREADS"
705703
log " Reactive: $SERVER_REACTIVE"
706704
log " Custom Sched: $SERVER_USE_CUSTOM_SCHEDULER"
707-
log " Scheduler Type: $SERVER_SCHEDULER_TYPE"
708705
log " I/O Type: $SERVER_IO"
709706
log " No Timeout: $SERVER_NO_TIMEOUT"
710707
log " Poller Mode: $SERVER_POLLER_MODE"
@@ -791,7 +788,6 @@ Handoff Server:
791788
SERVER_THREADS Number of event loop threads (default: 2)
792789
SERVER_REACTIVE Use reactive handler with Reactor (default: false)
793790
SERVER_USE_CUSTOM_SCHEDULER Use custom Netty scheduler (default: false)
794-
SERVER_SCHEDULER_TYPE Scheduler type: fifo or lifo (default: fifo)
795791
SERVER_IO I/O type: epoll, nio, or io_uring (default: epoll)
796792
SERVER_NO_TIMEOUT Disable HTTP client timeout (default: false)
797793
SERVER_TASKSET CPU affinity range (default: "2,3")

benchmark-runner/src/main/java/io/netty/loom/benchmark/runner/HandoffHttpServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ private static void printUsage() {
381381
--mock-url <url> Mock server URL (default: http://localhost:8080/fruits)
382382
--threads <n> Number of event loop threads (default: 1)
383383
--use-custom-scheduler <bool> Use custom Netty scheduler (default: false, ignored if --reactive is true)
384-
--scheduler-type <fifo|lifo> Scheduler type for custom scheduler (default: fifo)
384+
--scheduler-type <fifo> Scheduler type for custom scheduler (default: fifo)
385385
--io <epoll|nio|io_uring> I/O type (default: epoll)
386386
--no-timeout <true|false> Disable HTTP client timeout (default: false)
387387
--reactive <true|false> Use reactive handler with Reactor (default: false)

core/src/main/java/io/netty/loom/EventLoopSchedulerType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
package io.netty.loom;
1616

1717
public enum EventLoopSchedulerType {
18-
FIFO, LIFO
18+
FIFO
1919
}

0 commit comments

Comments
 (0)