Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
27 changes: 27 additions & 0 deletions benchmarks/jmh/run-benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
set -euo pipefail

RESULTS_DIR="benchmarks/jmh/build/results/jmh"
AGGREGATE_FILE="$RESULTS_DIR/aggregate-results.txt"
mkdir -p "$RESULTS_DIR"

: > "$AGGREGATE_FILE"

for threads in 10 50 200 500 1000; do
echo "=== Running with threads=$threads ==="
./gradlew :benchmarks:jmh:jmh \
-Pjmh.includes=HttpsConnectionBenchmark \
-Pjmh.profilers=gc \
-Pjmh.iterations=3 \
-Pjmh.warmupIterations=1 \
-Pjmh.fork=1 \
-Pjmh.threads="$threads"

echo "" >> "$AGGREGATE_FILE"
echo "=== threads=$threads ===" >> "$AGGREGATE_FILE"
cat "$RESULTS_DIR/results.txt" >> "$AGGREGATE_FILE"
done

echo ""
echo "=== Aggregated results ==="
cat "$AGGREGATE_FILE"
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import com.linecorp.armeria.internal.common.NonWrappingRequestContext;
import com.linecorp.armeria.internal.common.util.TemporaryThreadLocals;
import com.linecorp.armeria.internal.server.RouteDecoratingService.InitialDispatcherService;
import com.linecorp.armeria.server.ConnectionContext;
import com.linecorp.armeria.server.HttpService;
import com.linecorp.armeria.server.ProxiedAddresses;
import com.linecorp.armeria.server.Route;
Expand Down Expand Up @@ -107,6 +108,7 @@ public final class DefaultServiceRequestContext
private final InetAddress clientAddress;
private final InetSocketAddress remoteAddress;
private final InetSocketAddress localAddress;
private final ConnectionContext connectionContext;

private boolean shouldReportUnloggedExceptions = true;

Expand Down Expand Up @@ -151,12 +153,14 @@ public DefaultServiceRequestContext(
RoutingResult routingResult, ExchangeType exchangeType,
HttpRequest req, @Nullable SSLSession sslSession, ProxiedAddresses proxiedAddresses,
InetAddress clientAddress, InetSocketAddress remoteAddress, InetSocketAddress localAddress,
ConnectionContext connectionContext,
long requestStartTimeNanos, long requestStartTimeMicros,
Supplier<? extends AutoCloseable> contextHook) {

this(cfg, ch, eventLoop, meterRegistry, sessionProtocol, id, routingContext, routingResult,
exchangeType, req, sslSession, proxiedAddresses, clientAddress, remoteAddress, localAddress,
null /* requestCancellationScheduler */, requestStartTimeNanos, requestStartTimeMicros,
connectionContext, null /* requestCancellationScheduler */,
requestStartTimeNanos, requestStartTimeMicros,
HttpHeaders.of(), HttpHeaders.of(), contextHook);
}

Expand All @@ -166,6 +170,7 @@ public DefaultServiceRequestContext(
RoutingResult routingResult, ExchangeType exchangeType,
HttpRequest req, @Nullable SSLSession sslSession, ProxiedAddresses proxiedAddresses,
InetAddress clientAddress, InetSocketAddress remoteAddress, InetSocketAddress localAddress,
ConnectionContext connectionContext,
@Nullable CancellationScheduler requestCancellationScheduler,
long requestStartTimeNanos, long requestStartTimeMicros,
HttpHeaders additionalResponseHeaders, HttpHeaders additionalResponseTrailers,
Expand Down Expand Up @@ -196,6 +201,7 @@ public DefaultServiceRequestContext(
this.clientAddress = requireNonNull(clientAddress, "clientAddress");
this.remoteAddress = requireNonNull(remoteAddress, "remoteAddress");
this.localAddress = requireNonNull(localAddress, "localAddress");
this.connectionContext = requireNonNull(connectionContext, "connectionContext");

log = RequestLog.builder(this);
log.startRequest(requestStartTimeNanos, requestStartTimeMicros);
Expand Down Expand Up @@ -255,11 +261,16 @@ public InetAddress clientAddress() {
return clientAddress;
}

@Override
@Nullable
protected Channel channel() {
return ch;
}
Comment on lines +264 to 267
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove incorrect @Nullable annotation from channel().

The channel() method is annotated with @Nullable, but the ch field is validated as non-null in the constructor (line 185: requireNonNull(ch, "ch")), so this method always returns a non-null value.

🔧 Proposed fix
-    `@Nullable`
     protected Channel channel() {
         return ch;
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Nullable
protected Channel channel() {
return ch;
}
protected Channel channel() {
return ch;
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@core/src/main/java/com/linecorp/armeria/internal/server/DefaultServiceRequestContext.java`
around lines 264 - 267, The channel() accessor is wrongly annotated `@Nullable`
despite ch being required non-null in the constructor; remove the `@Nullable`
annotation from the channel() method (or replace it with a non-null annotation
if your codebase uses one) so the signature correctly reflects that channel()
always returns a non-null Channel; locate the method named channel() and the ch
field/constructor check to make the change.


@Override
public ConnectionContext connectionContext() {
return connectionContext;
}
Comment on lines +269 to +272
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add Javadoc for the new public method.

The connectionContext() method is public and requires Javadoc documentation. As per coding guidelines, all public and protected methods must have Javadoc.

📝 Suggested Javadoc
+    /**
+     * Returns the {`@link` ConnectionContext} for this request.
+     */
     `@Override`
     public ConnectionContext connectionContext() {

As per coding guidelines: "ensure all public classes and public/protected methods have Javadoc."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Override
public ConnectionContext connectionContext() {
return connectionContext;
}
/**
* Returns the {`@link` ConnectionContext} for this request.
*/
`@Override`
public ConnectionContext connectionContext() {
return connectionContext;
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@core/src/main/java/com/linecorp/armeria/internal/server/DefaultServiceRequestContext.java`
around lines 269 - 272, Add a Javadoc comment to the public method
connectionContext() in class DefaultServiceRequestContext explaining what it
returns (the associated ConnectionContext for this request), any
threading/ownership assumptions or lifecycle notes (e.g., non-null and valid for
the lifetime of the request context), and include the `@return` tag describing the
ConnectionContext; reference the method name connectionContext() and the class
DefaultServiceRequestContext when locating where to add the comment.


@Override
public ServiceConfig config() {
return cfg;
Expand Down
Loading
Loading