HttpChannel, AdaptiveExecutionStrategy: improve profiler-friendliness

In an application with multiple Jetty instances in one JVM (e.g. integration test)
when examining stack frames using the debugger or profiler, most samples
that involve user code will have these two frames in their stack.

Unfortunately, with a lambda, the different Jetty instances actually have different class names
for different lambdas, which causes stack analysis to falsely think the frames are different.

It's a little uglier, but by replacing these two specific lambdas with anonymous classes with a stable name,
the profiler is able to see that the frames are in fact the same and collapse them, improving observability.
This commit is contained in:
Steven Schlansker 2023-07-14 14:03:11 -07:00 committed by Simone Bordet
parent 218c8d0fb0
commit 5db0c7b552
2 changed files with 18 additions and 7 deletions

View File

@ -494,15 +494,19 @@ public abstract class HttpChannel implements Runnable, HttpOutput.Interceptor
if (!_request.hasMetaData())
throw new IllegalStateException("state=" + _state);
dispatch(DispatcherType.REQUEST, () ->
dispatch(DispatcherType.REQUEST, new Dispatchable()
{
for (HttpConfiguration.Customizer customizer : _configuration.getCustomizers())
@Override
public void dispatch() throws IOException, ServletException
{
customizer.customize(getConnector(), _configuration, _request);
if (_request.isHandled())
return;
for (HttpConfiguration.Customizer customizer : _configuration.getCustomizers())
{
customizer.customize(getConnector(), _configuration, _request);
if (_request.isHandled())
return;
}
getServer().handle(HttpChannel.this);
}
getServer().handle(HttpChannel.this);
});
break;

View File

@ -137,7 +137,14 @@ public class AdaptiveExecutionStrategy extends ContainerLifeCycle implements Exe
private final Executor _executor;
private final TryExecutor _tryExecutor;
private final Executor _virtualExecutor;
private final Runnable _runPendingProducer = () -> tryProduce(true);
private final Runnable _runPendingProducer = new Runnable()
{
@Override
public void run()
{
tryProduce(true);
}
};
private State _state = State.IDLE;
private boolean _pending;