Skip to content

JFR events support#82

Merged
franz1981 merged 7 commits intomasterfrom
jfr
Feb 4, 2026
Merged

JFR events support#82
franz1981 merged 7 commits intomasterfrom
jfr

Conversation

@franz1981
Copy link
Owner

@franz1981 franz1981 commented Jan 30, 2026

Fixes #5

I'm still working on:

  • finalize the JFR events in a form which work OOTB with JMC (which is what I'm struggling with ATM)
  • make sure this is not introducing any performance issue e.g. ATM I'm allocating a bit more on VT creation due to the SchedulingContext changes
  • Eventually provide some jbang script which process the JFR events to produce additional telemetry/charts and actionable data
  • Once JFR events are finalized write unit tests to make sure they work as intended

This is meant to understand if it makes sense to modify Netty to improve the "fairness" (see "Pareto Efficiency") of the scheduler vs I/O handling - which is supposed to be fast, but...better make sure it is.

In some later iteration I could provide an additional "context API" to allow binding the JFR events to HTTP request-related context - and even better - creating a custom scheduler for the purpose of instrumenting the built-in one as well too, and compare the two behaviours.

…ts. Update scripts to include new configurable options for trace and timeline exports. Add required helper scripts and resources.
@franz1981 franz1981 marked this pull request as ready for review February 2, 2026 07:02
… Update scripts, timeline viewer, and relevant classes to reflect changes.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive Java Flight Recorder (JFR) instrumentation to the Netty virtual thread scheduler, along with introducing FIFO and LIFO scheduler variants for performance comparison. The work includes custom JFR events for tracking scheduler activity, integration with the benchmark runner for capturing and analyzing JFR data, and a browser-based timeline viewer for visualizing scheduler behavior.

Changes:

  • Introduces five custom JFR events (NettyRunIo, NettyRunTasks, VirtualThreadTaskRuns, VirtualThreadTaskRun, VirtualThreadTaskSubmit) to instrument scheduler activity
  • Refactors EventLoopScheduler from a concrete class to an interface with FIFO and LIFO implementations
  • Extends SchedulingContext to track whether tasks are pollers and include scheduler references
  • Updates all tests to run against both FIFO and LIFO scheduler types
  • Adds complete JFR integration to the benchmark runner including event capture, timeline export via JfrToTimeline.java, and an HTML-based timeline viewer

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
core/src/main/java/io/netty/loom/jfr/*.java Five new JFR event definitions for scheduler instrumentation
core/src/main/java/io/netty/loom/SchedulerJfrUtil.java Helper utility for begin/commit patterns on JFR events
core/src/main/java/io/netty/loom/EventLoopScheduler.java Refactored from class to interface, with nested SharedRef and SchedulingContext classes
core/src/main/java/io/netty/loom/FifoEventLoopScheduler.java New FIFO implementation with JFR instrumentation
core/src/main/java/io/netty/loom/LifoEventLoopScheduler.java New LIFO implementation with JFR instrumentation
core/src/main/java/io/netty/loom/EventLoopSchedulerType.java New enum for FIFO/LIFO scheduler types
core/src/main/java/io/netty/loom/VirtualMultithreadIoEventLoopGroup.java Updated to support configurable scheduler type
core/src/main/java/io/netty/loom/NettyScheduler.java Updated for new SchedulingContext structure
core/src/test/java/io/netty/loom/VirtualMultithreadIoEventLoopGroupTest.java All tests parameterized to run against both scheduler types
benchmark-runner/src/main/java/io/netty/loom/benchmark/runner/HandoffHttpServer.java Added scheduler type CLI parameter
benchmark-runner/scripts/run-benchmark.sh Comprehensive JFR integration with event selection and timeline export
benchmark-runner/scripts/jfr/JfrToTimeline.java jbang script to convert JFR recordings to compact JSONL timeline format
benchmark-runner/scripts/jfr/timeline-viewer.html Browser-based interactive timeline visualization tool
benchmark-runner/scripts/jfr/netty-loom.jfc Default JFR settings file for Netty Loom events
benchmark-runner/README.md Documentation for JFR configuration and usage
README.md Overview of available JFR events

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@franz1981 franz1981 merged commit 6f55693 into master Feb 4, 2026
4 checks passed
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.

Implements custom scheduler event tracing

1 participant