gortiz commented on code in PR #18519: URL: https://github.com/apache/pinot/pull/18519#discussion_r3266800696
########## pinot-perf/src/main/java/org/apache/pinot/perf/BenchmarkGrpcMailboxSend.java: ########## @@ -0,0 +1,199 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.perf; + +import java.io.IOException; +import java.net.ServerSocket; +import java.util.Collections; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import org.apache.pinot.common.datatable.StatMap; +import org.apache.pinot.common.utils.DataSchema; +import org.apache.pinot.common.utils.DataSchema.ColumnDataType; +import org.apache.pinot.query.mailbox.MailboxService; +import org.apache.pinot.query.mailbox.ReceivingMailbox; +import org.apache.pinot.query.mailbox.SendingMailbox; +import org.apache.pinot.query.runtime.blocks.RowHeapDataBlock; +import org.apache.pinot.query.runtime.operator.MailboxSendOperator; +import org.apache.pinot.spi.config.instance.InstanceType; +import org.apache.pinot.spi.env.PinotConfiguration; +import org.apache.pinot.spi.query.QueryThreadContext; +import org.apache.pinot.spi.utils.CommonConstants; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.options.OptionsBuilder; + + +/// A/B benchmark for the gRPC sender-side back-pressure gate in `GrpcSendingMailbox`. +/// +/// Two real `MailboxService` instances run on localhost; a background drainer thread polls the +/// receiver as fast as it can. Crucially, the **drainer is rate-limited** (`@Param drainSleepMicros`) Review Comment: The benchmark was rewritten in commit `a597d63a64` ("Rewrite BenchmarkGrpcMailboxSend to ship 128 MiB per invocation"). The hot-loop-one-block measurement is gone; one `@Benchmark` invocation now ships 128 MiB split into pre-computed blocks and waits on a `CountDownLatch` for the receiver to fully drain. The drainer thread blocks on a `Semaphore` released by the receiver's `Reader::blockReadyToRead` callback — no spin, no sleep — so the `_drainSleepMicros` axis was removed entirely. The new axes are `_blockSizeBytes ∈ {8 KiB, 8 MiB, 32 MiB}`, `_backpressureEnabled`, `_flowControlWindowBytes ∈ {64 KiB, 1 MiB, 64 MiB}`. The class javadoc matches the new design. Full 18-cell results in the PR description. ########## pinot-query-runtime/src/main/java/org/apache/pinot/query/mailbox/channel/ChannelManager.java: ########## @@ -122,4 +123,14 @@ public boolean resetConnectBackoff(String hostname, int port) { private NettyChannelBuilder decorate(NettyChannelBuilder builder) { return builder.idleTimeout(_idleTimeout.getSeconds(), TimeUnit.SECONDS); } + + /// Exposes the metric view of the shared gRPC client allocator. The returned + /// metric covers every channel managed by this instance and reports both + /// `usedDirectMemory()` and `usedHeapMemory()`, so it remains meaningful + /// regardless of whether Netty is configured to prefer direct or heap buffers + /// (e.g. `-Dio.netty.noPreferDirect=true`). Consumed by [MailboxService] to + /// register the `MAILBOX_CLIENT_USED_*` gauges. + public PooledByteBufAllocatorMetric getBufAllocatorMetric() { Review Comment: Fixed in commit `6614b05834` ("Hide shaded PooledByteBufAllocatorMetric behind long accessors"). Both classes now expose plain `long` getters and keep the shaded type internal: * `ChannelManager.usedDirectMemoryBytes()` / `usedHeapMemoryBytes()` (`ChannelManager.java:149/156`) * `GrpcMailboxServer.usedDirectMemoryBytes()` / `usedHeapMemoryBytes()` (`GrpcMailboxServer.java:193/199`) `MailboxService` consumes only the `long` API, matching the `GrpcQueryServer` / `BrokerGrpcServer` precedent you cited. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
