zhuzhurk commented on code in PR #21779:
URL: https://github.com/apache/flink/pull/21779#discussion_r1090163123


##########
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/watermarkstatus/HeapPriorityQueue.java:
##########
@@ -0,0 +1,294 @@
+/*
+ * 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.flink.streaming.runtime.watermarkstatus;
+
+import javax.annotation.Nonnegative;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import java.util.Arrays;
+
+import static org.apache.flink.util.CollectionUtil.MAX_ARRAY_SIZE;
+
+/**
+ * This class is a copy of the {@link 
org.apache.flink.runtime.state.heap.HeapPriorityQueue}, which
+ * has the exact same logic with {@link 
org.apache.flink.runtime.state.heap.HeapPriorityQueue}. This
+ * class is introduced as the replacement to be used in {@link 
StatusWatermarkValve}, to avoid
+ * affecting the performance of memory state backend.
+ *
+ * <p>The reason why the performance of memory state backend will be affected 
if we reuse the {@link
+ * org.apache.flink.runtime.state.heap.HeapPriorityQueue}: In some scenarios, 
the {@link
+ * org.apache.flink.runtime.state.heap.HeapPriorityQueueElement} will only 
have one
+ * implementation(used by memory state backend), which allows the jvm to 
inline its
+ * methods(getInternalIndex, setInternalIndex). If we reuse it in {@link 
StatusWatermarkValve}, it
+ * will cause it to have multiple implementations. Once there are multiple 
implementations, its
+ * methods will be difficult to be inlined by jvm, which will result in poor 
performance of memory
+ * state backend.
+ *
+ * @param <T> type of the contained elements.
+ */
+public class HeapPriorityQueue<T extends 
HeapPriorityQueue.HeapPriorityQueueElement> {

Review Comment:
   We should also add tests for it.



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

Reply via email to