You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2021/03/08 06:45:11 UTC

[GitHub] [druid] abhishekagarwal87 commented on a change in pull request #10892: Avoid expensive findEntry call in segment metadata query

abhishekagarwal87 commented on a change in pull request #10892:
URL: https://github.com/apache/druid/pull/10892#discussion_r589201063



##########
File path: server/src/test/java/org/apache/druid/client/CachingClusteredClientPerfTest.java
##########
@@ -0,0 +1,255 @@
+/*
+ * 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.druid.client;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Ordering;
+import org.apache.druid.client.cache.CacheConfig;
+import org.apache.druid.client.cache.CachePopulator;
+import org.apache.druid.client.cache.MapCache;
+import org.apache.druid.client.selector.HighestPriorityTierSelectorStrategy;
+import org.apache.druid.client.selector.QueryableDruidServer;
+import org.apache.druid.client.selector.RandomServerSelectorStrategy;
+import org.apache.druid.client.selector.ServerSelector;
+import org.apache.druid.guice.http.DruidHttpClientConfig;
+import org.apache.druid.java.util.common.Intervals;
+import org.apache.druid.java.util.common.guava.Sequence;
+import org.apache.druid.java.util.common.guava.TestSequence;
+import org.apache.druid.query.BaseQuery;
+import org.apache.druid.query.DataSource;
+import org.apache.druid.query.DruidProcessingConfig;
+import org.apache.druid.query.Query;
+import org.apache.druid.query.QueryPlus;
+import org.apache.druid.query.QueryRunner;
+import org.apache.druid.query.QueryToolChest;
+import org.apache.druid.query.QueryToolChestWarehouse;
+import org.apache.druid.query.SegmentDescriptor;
+import org.apache.druid.query.TableDataSource;
+import org.apache.druid.query.context.ResponseContext;
+import org.apache.druid.query.filter.DimFilter;
+import org.apache.druid.query.spec.MultipleIntervalSegmentSpec;
+import org.apache.druid.query.spec.MultipleSpecificSegmentSpec;
+import org.apache.druid.query.spec.QuerySegmentSpec;
+import org.apache.druid.segment.TestHelper;
+import org.apache.druid.segment.join.NoopJoinableFactory;
+import org.apache.druid.server.QueryScheduler;
+import org.apache.druid.server.coordination.ServerManagerTest;
+import org.apache.druid.server.coordination.ServerType;
+import org.apache.druid.timeline.DataSegment;
+import org.apache.druid.timeline.VersionedIntervalTimeline;
+import org.apache.druid.timeline.partition.LinearShardSpec;
+import org.joda.time.Interval;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.ForkJoinPool;
+
+import static org.mockito.ArgumentMatchers.any;
+
+/**
+ * Performance tests for {@link CachingClusteredClient} can be added here. There is one test for a scenario
+ * where a single interval has large number of segments.
+ */
+public class CachingClusteredClientPerfTest
+{
+
+  @Test(timeout = 10_000)
+  public void testGetQueryRunnerForSegments_singleIntervalLargeSegments()
+  {
+    final int segmentCount = 30_000;
+    final Interval interval = Intervals.of("2021-02-13/2021-02-14");
+    final List<SegmentDescriptor> segmentDescriptors = new ArrayList<>(segmentCount);
+    final List<DataSegment> dataSegments = new ArrayList<>(segmentCount);
+    final VersionedIntervalTimeline<String, ServerSelector> timeline = new VersionedIntervalTimeline<>(Ordering.natural());
+    final DruidServer server = new DruidServer(
+        "server",
+        "localhost:9000",
+        null,
+        Long.MAX_VALUE,
+        ServerType.HISTORICAL,
+        DruidServer.DEFAULT_TIER,
+        DruidServer.DEFAULT_PRIORITY
+    );
+
+    for (int ii = 0; ii < segmentCount; ii++) {
+      segmentDescriptors.add(new SegmentDescriptor(interval, "1", ii));

Review comment:
       The bottlenecks are in `PartitionHolder` when it has too many objects. If segments have different intervals and versions, the size of `PartitionHolder` will be much smaller and there is unlikely to be a perf issue. 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org