Skip to content

Commit cf8e517

Browse files
committed
Remove support for "Immediate" tasks in JFR timeline viewer and related logic
1 parent 668dcbf commit cf8e517

6 files changed

Lines changed: 9 additions & 67 deletions

File tree

benchmark-runner/scripts/jfr/JfrToTimeline.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,6 @@ private static void writeEventLine(LineWriter writer,
160160
writer.writeAscii(",\"el\":");
161161
writer.writeAscii(event.getBoolean("isEventLoop") ? "1" : "0");
162162
}
163-
if (event.hasField("immediate")) {
164-
writer.writeAscii(",\"im\":");
165-
writer.writeAscii(event.getBoolean("immediate") ? "1" : "0");
166-
}
167163
if (event.hasField("canBlock")) {
168164
writer.writeAscii(",\"b\":");
169165
writer.writeAscii(event.getBoolean("canBlock") ? "1" : "0");

benchmark-runner/scripts/jfr/timeline-viewer.html

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -363,33 +363,7 @@ <h1>Netty Loom Timeline Viewer</h1>
363363
const VT_RUN_COLORS = {
364364
poller: '#e11d48',
365365
eventLoop: '#2563eb',
366-
immediate: '#f59e0b',
367366
};
368-
const VT_RUN_COMBO = mixColors(VT_RUN_COLORS.poller, VT_RUN_COLORS.immediate);
369-
370-
function mixColors(hexA, hexB) {
371-
const a = hexToRgb(hexA);
372-
const b = hexToRgb(hexB);
373-
const mix = {
374-
r: Math.round((a.r + b.r) / 2),
375-
g: Math.round((a.g + b.g) / 2),
376-
b: Math.round((a.b + b.b) / 2),
377-
};
378-
return `rgb(${mix.r}, ${mix.g}, ${mix.b})`;
379-
}
380-
381-
function hexToRgb(hex) {
382-
const clean = hex.replace('#', '');
383-
const value = clean.length === 3
384-
? clean.split('').map(c => c + c).join('')
385-
: clean;
386-
const intVal = parseInt(value, 16);
387-
return {
388-
r: (intVal >> 16) & 255,
389-
g: (intVal >> 8) & 255,
390-
b: intVal & 255,
391-
};
392-
}
393367

394368
function carrierColor(tid) {
395369
const hue = (tid * 29) % 360;
@@ -461,7 +435,6 @@ <h1>Netty Loom Timeline Viewer</h1>
461435
thread.v.push(obj.v || 0);
462436
thread.p.push(obj.p ?? null);
463437
thread.el.push(obj.el ?? null);
464-
thread.im.push(obj.im ?? null);
465438
thread.b.push(obj.b ?? null);
466439
thread.te.push(obj.te ?? null);
467440
thread.q0.push(obj.q0 ?? null);
@@ -487,7 +460,7 @@ <h1>Netty Loom Timeline Viewer</h1>
487460
function getThread(tid) {
488461
let thread = state.threads.get(tid);
489462
if (!thread) {
490-
thread = { tid, name: `tid-${tid}`, s: [], d: [], n: [], v: [], p: [], el: [], im: [], b: [], te: [], q0: [], q1: [], io: [], th: [], st: [] };
463+
thread = { tid, name: `tid-${tid}`, s: [], d: [], n: [], v: [], p: [], el: [], b: [], te: [], q0: [], q1: [], io: [], th: [], st: [] };
491464
state.threads.set(tid, thread);
492465
}
493466
return thread;
@@ -508,7 +481,6 @@ <h1>Netty Loom Timeline Viewer</h1>
508481
thread.v = order.map(i => thread.v[i]);
509482
thread.p = order.map(i => thread.p[i]);
510483
thread.el = order.map(i => thread.el[i]);
511-
thread.im = order.map(i => thread.im[i]);
512484
thread.b = order.map(i => thread.b[i]);
513485
thread.te = order.map(i => thread.te[i]);
514486
thread.q0 = order.map(i => thread.q0[i]);
@@ -743,18 +715,13 @@ <h1>Netty Loom Timeline Viewer</h1>
743715
clampedX2 = tmp;
744716
}
745717
let color = eventColor(n[i]);
746-
if (state.events[n[i]] === VT_RUN_EVENT_NAME || state.events[n[i]] === VT_SUBMIT_EVENT_NAME) {
718+
if (state.events[n[i]] === VT_RUN_EVENT_NAME || state.events[n[i]] === VT_SUBMIT_EVENT_NAME) {
747719
const isPoller = thread.p[i] === 1 || thread.p[i] === true;
748720
const isEventLoop = thread.el[i] === 1 || thread.el[i] === true;
749-
const isImmediate = thread.im[i] === 1 || thread.im[i] === true;
750721
if (isEventLoop) {
751722
color = VT_RUN_COLORS.eventLoop;
752-
} else if (isPoller && isImmediate) {
753-
color = VT_RUN_COMBO;
754723
} else if (isPoller) {
755724
color = VT_RUN_COLORS.poller;
756-
} else if (isImmediate) {
757-
color = VT_RUN_COLORS.immediate;
758725
}
759726
}
760727
ctx.fillStyle = color;
@@ -931,7 +898,6 @@ <h1>Netty Loom Timeline Viewer</h1>
931898
const vtid = thread.v[eventIdx];
932899
const isPoller = thread.p[eventIdx];
933900
const isEventLoop = thread.el[eventIdx];
934-
const isImmediate = thread.im[eventIdx];
935901
const canBlock = thread.b[eventIdx];
936902
const tasksExecuted = thread.te[eventIdx];
937903
const queueDepthBefore = thread.q0[eventIdx];
@@ -956,9 +922,6 @@ <h1>Netty Loom Timeline Viewer</h1>
956922
if (isEventLoop != null) {
957923
tooltipText += `\nIsEventLoop: ${isEventLoop ? 'true' : 'false'}`;
958924
}
959-
if (isImmediate != null) {
960-
tooltipText += `\nImmediate: ${isImmediate ? 'true' : 'false'}`;
961-
}
962925
if (canBlock != null) {
963926
tooltipText += `\nCanBlock: ${canBlock ? 'true' : 'false'}`;
964927
}

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

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ private boolean runEventLoopContinuation() {
174174
var eventLoopContinuation = this.eventLoopContinuatioToRun;
175175
if (eventLoopContinuation != null) {
176176
this.eventLoopContinuatioToRun = null;
177-
runContinuation(eventLoopContinuation, false);
177+
runContinuation(eventLoopContinuation);
178178
return true;
179179
}
180180
return false;
@@ -230,7 +230,7 @@ private int runExternalContinuations(long deadlineNs) {
230230
break;
231231
}
232232
runContinuations++;
233-
runContinuation(task, false);
233+
runContinuation(task);
234234
long elapsedNs = System.nanoTime() - startDrainingNs;
235235
if (elapsedNs >= deadlineNs) {
236236
break;
@@ -269,7 +269,7 @@ public boolean execute(Thread.VirtualThreadTask task) {
269269
}
270270
if (submitEventEnabled) {
271271
SchedulerJfrUtil.commitVirtualThreadTaskSubmitEvent(task, currentThread, carrierThread, context.isPoller,
272-
eventLoopTask, false);
272+
eventLoopTask);
273273
}
274274
if (currentThread != eventLoopThread) {
275275
// currentThread == carrierThread iff
@@ -282,19 +282,11 @@ public boolean execute(Thread.VirtualThreadTask task) {
282282
LockSupport.unpark(parkedCarrierThread);
283283
}
284284
}
285-
} else if (!eventLoopTask && !eventLoopIsRunning.get()) {
286-
// the event loop thread is allowed to give up cycles to consume external
287-
// continuations
288-
// whilst is just woken up for I/O
289-
assert eventLoopContinuatioToRun == null;
290-
if (!runQueue.isEmpty()) {
291-
Thread.yield();
292-
}
293285
}
294286
return true;
295287
}
296288

297-
private void runContinuation(Thread.VirtualThreadTask task, boolean immediate) {
289+
private void runContinuation(Thread.VirtualThreadTask task) {
298290
var event = SchedulerJfrUtil.beginVirtualThreadTaskRunEvent();
299291
if (event == null) {
300292
task.run();
@@ -303,8 +295,7 @@ private void runContinuation(Thread.VirtualThreadTask task, boolean immediate) {
303295
boolean isEventLoop = task.thread() == eventLoopThread;
304296
boolean isPoller = ((SchedulingContext) task.attachment()).isPoller;
305297
task.run();
306-
SchedulerJfrUtil.commitVirtualThreadTaskRunEvent(event, carrierThread, task.thread(), isPoller, isEventLoop,
307-
immediate);
298+
SchedulerJfrUtil.commitVirtualThreadTaskRunEvent(event, carrierThread, task.thread(), isPoller, isEventLoop);
308299
}
309300

310301
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,25 +89,23 @@ public static void commitVirtualThreadTaskRunsEvent(VirtualThreadTaskRunsEvent e
8989
}
9090

9191
public static void commitVirtualThreadTaskRunEvent(VirtualThreadTaskRunEvent event, Thread carrierThread,
92-
Thread virtualThread, boolean isPoller, boolean isEventLoop, boolean immediate) {
92+
Thread virtualThread, boolean isPoller, boolean isEventLoop) {
9393
event.end();
9494
event.carrierThread = carrierThread;
9595
event.virtualThread = virtualThread;
9696
event.isPoller = isPoller;
9797
event.isEventLoop = isEventLoop;
98-
event.immediate = immediate;
9998
event.commit();
10099
}
101100

102101
public static void commitVirtualThreadTaskSubmitEvent(Thread.VirtualThreadTask task, Thread submitterThread,
103-
Thread carrierThread, boolean isPoller, boolean isEventLoop, boolean immediate) {
102+
Thread carrierThread, boolean isPoller, boolean isEventLoop) {
104103
var event = new VirtualThreadTaskSubmitEvent();
105104
event.virtualThread = task.thread();
106105
event.submitterThread = submitterThread;
107106
event.carrierThread = carrierThread;
108107
event.isPoller = isPoller;
109108
event.isEventLoop = isEventLoop;
110-
event.immediate = immediate;
111109
event.commit();
112110
}
113111

core/src/main/java/io/netty/loom/jfr/VirtualThreadTaskRunEvent.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ public final class VirtualThreadTaskRunEvent extends Event {
4545
@Label("Is Event Loop")
4646
public boolean isEventLoop;
4747

48-
@Label("Immediate")
49-
public boolean immediate;
50-
5148
public static boolean isEventEnabled() {
5249
return EVENT_TYPE.isEnabled();
5350
}

core/src/main/java/io/netty/loom/jfr/VirtualThreadTaskSubmitEvent.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ public final class VirtualThreadTaskSubmitEvent extends Event {
4848
@Label("Is Event Loop")
4949
public boolean isEventLoop;
5050

51-
@Label("Immediate")
52-
public boolean immediate;
53-
5451
public static boolean isEventEnabled() {
5552
return EVENT_TYPE.isEnabled();
5653
}

0 commit comments

Comments
 (0)