-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Faster batch segment allocation by reducing metadata IO #17420
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,6 @@ | |
import org.apache.druid.indexing.common.task.IndexTaskUtils; | ||
import org.apache.druid.indexing.common.task.Task; | ||
import org.apache.druid.indexing.overlord.IndexerMetadataStorageCoordinator; | ||
import org.apache.druid.indexing.overlord.Segments; | ||
import org.apache.druid.indexing.overlord.TaskLockbox; | ||
import org.apache.druid.indexing.overlord.config.TaskLockConfig; | ||
import org.apache.druid.java.util.common.ISE; | ||
|
@@ -41,6 +40,7 @@ | |
import org.apache.druid.query.DruidMetrics; | ||
import org.apache.druid.segment.realtime.appenderator.SegmentIdWithShardSpec; | ||
import org.apache.druid.timeline.DataSegment; | ||
import org.apache.druid.timeline.Partitions; | ||
import org.joda.time.Interval; | ||
|
||
import java.util.ArrayList; | ||
|
@@ -87,6 +87,8 @@ public class SegmentAllocationQueue | |
private final ConcurrentHashMap<AllocateRequestKey, AllocateRequestBatch> keyToBatch = new ConcurrentHashMap<>(); | ||
private final BlockingDeque<AllocateRequestBatch> processingQueue = new LinkedBlockingDeque<>(MAX_QUEUE_SIZE); | ||
|
||
private final boolean skipSegmentPayloadFetchForAllocation; | ||
|
||
@Inject | ||
public SegmentAllocationQueue( | ||
TaskLockbox taskLockbox, | ||
|
@@ -100,6 +102,7 @@ public SegmentAllocationQueue( | |
this.taskLockbox = taskLockbox; | ||
this.metadataStorage = metadataStorage; | ||
this.maxWaitTimeMillis = taskLockConfig.getBatchAllocationWaitTime(); | ||
this.skipSegmentPayloadFetchForAllocation = taskLockConfig.isSegmentAllocationReduceMetadataIO(); | ||
|
||
this.executor = taskLockConfig.isBatchSegmentAllocation() | ||
? executorFactory.create(1, "SegmentAllocQueue-%s") : null; | ||
|
@@ -380,13 +383,11 @@ private boolean processBatch(AllocateRequestBatch requestBatch) | |
|
||
private Set<DataSegment> retrieveUsedSegments(AllocateRequestKey key) | ||
{ | ||
return new HashSet<>( | ||
metadataStorage.retrieveUsedSegmentsForInterval( | ||
key.dataSource, | ||
key.preferredAllocationInterval, | ||
Segments.ONLY_VISIBLE | ||
) | ||
); | ||
return metadataStorage.getSegmentTimelineForAllocation( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it inefficient here if skipSegmentPayloadFetchForAllocation is true? We are getting segments from retrieveUsedSegmentsForAllocation then creating a timeline via SegmentTimeline.forSegments and then getting segments back again via findNonOvershadowedObjectsInInterval. Why do we even need to create a timeline? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean when it is false? |
||
key.dataSource, | ||
key.preferredAllocationInterval, | ||
(key.lockGranularity == LockGranularity.TIME_CHUNK) && skipSegmentPayloadFetchForAllocation | ||
).findNonOvershadowedObjectsInInterval(Intervals.ETERNITY, Partitions.ONLY_COMPLETE); | ||
} | ||
|
||
private int allocateSegmentsForBatch(AllocateRequestBatch requestBatch, Set<DataSegment> usedSegments) | ||
|
@@ -493,7 +494,8 @@ private int allocateSegmentsForInterval( | |
requestKey.dataSource, | ||
tryInterval, | ||
requestKey.skipSegmentLineageCheck, | ||
requestKey.lockGranularity | ||
requestKey.lockGranularity, | ||
skipSegmentPayloadFetchForAllocation | ||
); | ||
|
||
int successfulRequests = 0; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename as suggested.