jiangxin369 commented on code in PR #250:
URL: https://github.com/apache/flink-ml/pull/250#discussion_r1292700690


##########
flink-ml-core/src/test/java/org/apache/flink/iteration/datacache/nonkeyed/ListStateWithCacheTest.java:
##########
@@ -0,0 +1,169 @@
+/*
+ * 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.iteration.datacache.nonkeyed;
+
+import org.apache.flink.api.common.typeinfo.Types;
+import org.apache.flink.api.common.typeutils.base.StringSerializer;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.MemorySize;
+import org.apache.flink.configuration.RestOptions;
+import org.apache.flink.configuration.TaskManagerOptions;
+import org.apache.flink.ml.common.datastream.DataStreamUtils;
+import org.apache.flink.ml.util.TestUtils;
+import org.apache.flink.runtime.jobgraph.JobGraph;
+import org.apache.flink.runtime.memory.MemoryReservationException;
+import org.apache.flink.runtime.minicluster.MiniCluster;
+import org.apache.flink.runtime.minicluster.MiniClusterConfiguration;
+import org.apache.flink.runtime.state.StateInitializationContext;
+import org.apache.flink.runtime.state.StateSnapshotContext;
+import org.apache.flink.streaming.api.datastream.DataStream;
+import 
org.apache.flink.streaming.api.environment.ExecutionCheckpointingOptions;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.streaming.api.functions.sink.SinkFunction;
+import org.apache.flink.streaming.api.operators.AbstractStreamOperator;
+import org.apache.flink.streaming.api.operators.BoundedOneInput;
+import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
+import org.apache.flink.streaming.api.operators.StreamOperatorStateHandler;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.testcontainers.shaded.org.apache.commons.lang3.RandomStringUtils;
+
+/** Tests {@link ListStateWithCache}. */
+public class ListStateWithCacheTest {
+
+    @Rule public TemporaryFolder tempFolder = new TemporaryFolder();
+
+    private MiniClusterConfiguration createMiniClusterConfiguration() {
+        Configuration configuration = new Configuration();
+        // Set managed memory size to a small value, so when the instance of 
ListStateWithCache
+        // tries to allocate memory, it will use up all managed memory 
assigned to itself.
+        configuration.set(TaskManagerOptions.MANAGED_MEMORY_SIZE, 
MemorySize.ofMebiBytes(16));
+        configuration.set(RestOptions.PORT, 18082);

Review Comment:
   Do we need this config?



##########
flink-ml-iteration/flink-ml-iteration-common/src/main/java/org/apache/flink/iteration/datacache/nonkeyed/ListStateWithCache.java:
##########
@@ -62,14 +63,32 @@ public class ListStateWithCache<T> implements ListState<T> {
     /** The data cache writer for the received records. */
     private final DataCacheWriter<T> dataCacheWriter;
 
-    @SuppressWarnings("unchecked")
     public ListStateWithCache(
             TypeSerializer<T> serializer,
             StreamTask<?, ?> containingTask,
             StreamingRuntimeContext runtimeContext,
             StateInitializationContext stateInitializationContext,
             OperatorID operatorID)
             throws IOException {
+        this(
+                serializer,
+                containingTask,
+                runtimeContext,
+                stateInitializationContext,
+                operatorID,
+                0.);

Review Comment:
   With this constructor, the current algorithms using `ListStateWithCache` 
like `Kmeans` would not use managed memory at all, which causes performance 
regression.
   
   Would it be better if we divide the memory evenly if multiple 
`ListStateWithCache` is used by default?



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