mirror of https://github.com/apache/druid.git
Improve performance of queries against SYSTEM.SEGMENT table. (#11008)
Size HashMap and HashSet appropriately. Perf analysis of the queries revealed that over 25% of the query time was spent in resizing HashMap and HashSet collections. Also, prevent the need to examine and authorize all resources when AllowAllAuthorizer is the configured authorizer.
This commit is contained in:
parent
3d7e7c2c83
commit
83fcab1d0f
|
@ -263,6 +263,10 @@ public class AuthorizationUtils
|
|||
throw new ISE("No authorizer found with name: [%s].", authenticationResult.getAuthorizerName());
|
||||
}
|
||||
|
||||
if (authorizer instanceof AllowAllAuthorizer) {
|
||||
return resources;
|
||||
}
|
||||
|
||||
final Map<ResourceAction, Access> resultCache = new HashMap<>();
|
||||
final Iterable<ResType> filteredResources = Iterables.filter(
|
||||
resources,
|
||||
|
|
|
@ -702,13 +702,14 @@ public class DruidSchema extends AbstractSchema
|
|||
|
||||
Map<SegmentId, AvailableSegmentMetadata> getSegmentMetadataSnapshot()
|
||||
{
|
||||
final Map<SegmentId, AvailableSegmentMetadata> segmentMetadata = new HashMap<>();
|
||||
synchronized (lock) {
|
||||
final Map<SegmentId, AvailableSegmentMetadata> segmentMetadata = Maps.newHashMapWithExpectedSize(
|
||||
segmentMetadataInfo.values().stream().mapToInt(v -> v.size()).sum());
|
||||
for (TreeMap<SegmentId, AvailableSegmentMetadata> val : segmentMetadataInfo.values()) {
|
||||
segmentMetadata.putAll(val);
|
||||
}
|
||||
return segmentMetadata;
|
||||
}
|
||||
return segmentMetadata;
|
||||
}
|
||||
|
||||
int getTotalSegments()
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.google.common.collect.FluentIterable;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.net.HostAndPort;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.inject.Inject;
|
||||
|
@ -90,7 +91,6 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -287,7 +287,7 @@ public class SystemSchema extends AbstractSchema
|
|||
// Coordinator.
|
||||
final Iterator<SegmentWithOvershadowedStatus> metadataStoreSegments = metadataView.getPublishedSegments();
|
||||
|
||||
final Set<SegmentId> segmentsAlreadySeen = new HashSet<>();
|
||||
final Set<SegmentId> segmentsAlreadySeen = Sets.newHashSetWithExpectedSize(druidSchema.getTotalSegments());
|
||||
|
||||
final FluentIterable<Object[]> publishedSegments = FluentIterable
|
||||
.from(() -> getAuthorizedPublishedSegments(metadataStoreSegments, root))
|
||||
|
|
Loading…
Reference in New Issue