@@ -45,12 +45,13 @@ public static ServerBuilder<?> forPort(int port) {
4545 }
4646
4747 /**
48- * Execute application code directly in the transport thread.
49- *
50- * <p>Depending on the underlying transport, using a direct executor may lead to substantial
51- * performance improvements. However, it also requires the application to not block under
48+ * Execute application code directly in the transport thread. The application must not block under
5249 * any circumstances.
5350 *
51+ * <p>Depending on the underlying transport and the application code, using a direct executor may
52+ * lead to 10s of µs latency reduction but causes a substantial performance degradation when
53+ * misused.
54+ *
5455 * <p>Calling this method is semantically equivalent to calling {@link #executor(Executor)} and
5556 * passing in a direct executor. However, this is the preferred way as it may allow the transport
5657 * to perform special optimizations.
@@ -61,10 +62,11 @@ public static ServerBuilder<?> forPort(int port) {
6162 public abstract T directExecutor ();
6263
6364 /**
64- * Provides a custom executor.
65+ * Set the default executor for service callbacks .
6566 *
6667 * <p>It's an optional parameter. If the user has not provided an executor when the server is
67- * built, the builder will use a static cached thread pool.
68+ * built, the builder will use a static cached thread pool. Users are encouraged to specify their
69+ * own executor that limits the number of threads.
6870 *
6971 * <p>The server won't take ownership of the given executor. It's caller's responsibility to
7072 * shut down the executor when it's desired.
@@ -85,11 +87,13 @@ public static ServerBuilder<?> forPort(int port) {
8587 * it switches over. But if calling {@link ServerCallExecutorSupplier} returns null, the server
8688 * call is still handled by the default {@link #executor(Executor)} as a fallback.
8789 *
90+ * <p>If your {@code executorSupplier} runs quickly and always returns a non-{@code null}
91+ * executor, then you may want to use {@link #directExecutor} to reduce latency.
92+ *
8893 * @param executorSupplier the server call executor provider
8994 * @return this
9095 * @since 1.39.0
91- *
92- * */
96+ */
9397 @ ExperimentalApi ("https://github.com/grpc/grpc-java/issues/8274" )
9498 public T callExecutor (ServerCallExecutorSupplier executorSupplier ) {
9599 return thisT ();
0 commit comments