cryptoe commented on code in PR #13909: URL: https://github.com/apache/druid/pull/13909#discussion_r1139817347
########## extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/counters/SegmentGenerationProgressCounter.java: ########## @@ -0,0 +1,142 @@ +/* + * 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.msq.counters; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.google.errorprone.annotations.concurrent.GuardedBy; + +import javax.annotation.Nullable; +import java.util.Objects; + +/** + * Counters for segment generation phase. Created by {@link CounterTracker#segmentGenerationProgress()}. + */ +public class SegmentGenerationProgressCounter implements QueryCounter +{ + @GuardedBy("this") + private long rowsProcessed = 0L; + + @GuardedBy("this") + private long rowsPersisted = 0L; + + @GuardedBy("this") + private long rowsMerged = 0L; + + public void incrementRowProcessedCount() Review Comment: Can we take a lock once and increment all three metrics ? ########## extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/indexing/SegmentGeneratorFrameProcessor.java: ########## @@ -202,7 +211,14 @@ private void addFrame(final Frame frame) try { rowsWritten++; + segmentGenerationProgressCounter.incrementRowProcessedCount(); appenderator.add(segmentIdWithShardSpec, inputRow, null); + if (rowsWritten - lastCounterUpdatedRows > 1000) { Review Comment: The the current approach, you will miss the last batch rite ? So if total rows are 1950, you would only have metrics for the first 1000 rows. ########## server/src/main/java/org/apache/druid/segment/realtime/appenderator/BatchAppenderator.java: ########## @@ -785,6 +785,9 @@ private DataSegment mergeAndPush( for (FireHydrant fireHydrant : sink) { Pair<ReferenceCountingSegment, Closeable> segmentAndCloseable = fireHydrant.getAndIncrementSegment(); final QueryableIndex queryableIndex = segmentAndCloseable.lhs.asQueryableIndex(); + if (queryableIndex != null) { Review Comment: Why would the queryable index by empty here. Would it cause problems in the indexes.add() method ? ########## extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/indexing/SegmentGeneratorFrameProcessor.java: ########## @@ -202,7 +211,14 @@ private void addFrame(final Frame frame) try { rowsWritten++; + segmentGenerationProgressCounter.incrementRowProcessedCount(); appenderator.add(segmentIdWithShardSpec, inputRow, null); + if (rowsWritten - lastCounterUpdatedRows > 1000) { Review Comment: Lets increment stuff on each added row since we are fetching from an atomic long and the slowest operation would be the merging step anyway. ########## server/src/main/java/org/apache/druid/segment/realtime/FireDepartmentMetrics.java: ########## @@ -113,6 +114,9 @@ public void incrementMergeTimeMillis(long millis) { mergeTimeMillis.addAndGet(millis); } + public void incrementMergeRows(long rows) { Review Comment: Can you please document what merge rows mean's ? -- 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]
