yandrey321 commented on code in PR #11226: URL: https://github.com/apache/ozone/pull/11226#discussion_r4039694803
########## hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOfsGetFileStatusCacheBenchmark.java: ########## @@ -0,0 +1,367 @@ +/* + * 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.hadoop.fs.ozone; + +import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY; +import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ADDRESS_KEY; +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Random; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicReference; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.fs.contract.ContractTestUtils; +import org.apache.hadoop.hdds.conf.OzoneConfiguration; +import org.apache.hadoop.hdds.utils.IOUtils; +import org.apache.hadoop.ozone.MiniOzoneCluster; +import org.apache.hadoop.ozone.OzoneConsts; +import org.apache.hadoop.ozone.client.BucketArgs; +import org.apache.hadoop.ozone.client.ObjectStore; +import org.apache.hadoop.ozone.client.OzoneClient; +import org.apache.hadoop.ozone.client.OzoneVolume; +import org.apache.hadoop.ozone.om.OMConfigKeys; +import org.apache.hadoop.ozone.om.OMMetrics; +import org.apache.hadoop.ozone.om.helpers.BucketLayout; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Benchmark for the OFS getFileStatus bucket-layout cache (HDDS-15925). + * + * <p>Runs a cache-hit-heavy getFileStatus workload against one + * {@link MiniOzoneCluster} using the default client configuration, and reports + * the InfoBucket RPCs, getFileStatus RPCs, per-call latency (mean/p50/p90/p99/ + * max) and throughput measured by OM. The workload touches {@link #NUM_BUCKETS} + * buckets {@link #ACCESSES_PER_BUCKET} times each, so exactly one access per + * bucket is a cold miss and the rest would hit a per-bucket layout cache — a + * 90% cache-hit workload. + * + * <p>This benchmark makes no assumption about whether the cache exists, so the + * identical test runs on both the optimized branch and the baseline + * ({@code master}) code. The before/after comparison is what OM reports for the + * same workload: + * <ul> + * <li>baseline (no cache): two RPCs per getFileStatus (InfoBucket + + * getFileStatus), one InfoBucket RPC per call ({@link #TOTAL_CALLS});</li> + * <li>optimized (cache on by default): one RPC per cache hit, so one + * InfoBucket RPC per distinct bucket ({@link #NUM_BUCKETS});</li> + * <li>server-side (HDDS-15925 -alt): getFileStatus talks to OM directly, so + * the InfoBucket RPC is removed entirely (zero for the workload).</li> + * </ul> + * The getFileStatus RPC count is identical either way, showing the optimization + * removes only the redundant InfoBucket RPC and changes no behaviour; the + * latency percentiles show the effect of dropping that RPC per call. + * + * <p>A second test runs the same workload single-threaded and then across + * {@link #CONCURRENT_THREADS} client threads sharing one {@code FileSystem} (and + * thus one layout cache), and logs the two side by side. It confirms the atomic + * get-or-load holds the InfoBucket RPC count at one per bucket under concurrency + * — concurrent cold misses on the same bucket collapse to a single RPC instead + * of stampeding — while throughput scales with the added client threads. + */ +@Tag("benchmark") +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +public class TestOfsGetFileStatusCacheBenchmark { Review Comment: fixed: CI is green: https://github.com/yandrey321/ozone/actions/runs/35241829734 -- 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]
