ibessonov commented on code in PR #6271: URL: https://github.com/apache/ignite-3/pull/6271#discussion_r2213516553
########## modules/storage-page-memory/src/test/java/org/apache/ignite/internal/storage/pagememory/benchmarks/SortedIndexTreeInsertBenchmark.java: ########## @@ -0,0 +1,217 @@ +/* + * 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.ignite.internal.storage.pagememory.benchmarks; + +import static org.apache.ignite.internal.pagememory.PageIdAllocator.FLAG_AUX; + +import java.nio.ByteBuffer; +import java.util.List; +import java.util.Random; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; +import java.util.function.Supplier; +import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder; +import org.apache.ignite.internal.pagememory.PageMemory; +import org.apache.ignite.internal.pagememory.configuration.VolatileDataRegionConfiguration; +import org.apache.ignite.internal.pagememory.freelist.FreeListImpl; +import org.apache.ignite.internal.pagememory.inmemory.VolatilePageMemory; +import org.apache.ignite.internal.pagememory.io.PageIoRegistry; +import org.apache.ignite.internal.storage.RowId; +import org.apache.ignite.internal.storage.index.StorageSortedIndexDescriptor; +import org.apache.ignite.internal.storage.index.StorageSortedIndexDescriptor.StorageSortedIndexColumnDescriptor; +import org.apache.ignite.internal.storage.pagememory.index.freelist.IndexColumns; +import org.apache.ignite.internal.storage.pagememory.index.sorted.SortedIndexRow; +import org.apache.ignite.internal.storage.pagememory.index.sorted.SortedIndexTree; +import org.apache.ignite.internal.type.NativeType; +import org.apache.ignite.internal.type.NativeTypes; +import org.apache.ignite.internal.util.Constants; +import org.apache.ignite.internal.util.OffheapReadWriteLock; +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.Options; +import org.openjdk.jmh.runner.options.OptionsBuilder; + +/** + * A micro-benchmark for sorted index tree in a volatile data region. + * + * <p>In this benchmark the warmup must be much longer than the measurement. This is because the insertion duration correlates with a tree + * height, which grows logarithmically with the number of inserted rows. Logarithm starts to grow slowly only after a certain threshold, but + * before that it grows very quickly. We want to exhaust that growth before we start measuring the performance. + */ +@Warmup(iterations = 20, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) +@Fork(1) +@BenchmarkMode(Mode.Throughput) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@State(Scope.Thread) +public class SortedIndexTreeInsertBenchmark { + /** Size of a data region. Should be large enough to fit all the data in this benchmark. */ + private static final long REGION_SIZE = 4L * Constants.GiB; + + /** Page size. We may want to make it configurable in the future. Let's use a more performant 4Kb for now. */ + private static final int PAGE_SIZE = 4 * Constants.KiB; + + /** Group ID constant for the benchmark. Could be anything. */ + private static final int GROUP_ID = 1; + /** Partition ID constant for the benchmark. Could be anything. */ + private static final int PARTITION_ID = 0; + /** Index ID constant for the benchmark. Could be anything. */ + private static final int INDEX_ID = 1; + + /** Some fake row ID for benchmark. Reused in all operations, because allocating a new one every time is slow. */ + private static final RowId ROW_ID = new RowId(PARTITION_ID); + + /** An instance of {@link Random}. */ + private static final Random RANDOM = new Random(System.currentTimeMillis()); Review Comment: There's no need to have a thread-local random here, benchmark is single-threaded -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org