flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [flink] zhuzhurk commented on a change in pull request #10200: [FLINK-14062][runtime] Calculate managed memory fraction based on slot sharing groups
Date Sat, 16 Nov 2019 10:15:03 GMT
zhuzhurk commented on a change in pull request #10200: [FLINK-14062][runtime] Calculate managed
memory fraction based on slot sharing groups
URL: https://github.com/apache/flink/pull/10200#discussion_r347085720
 
 

 ##########
 File path: flink-streaming-java/src/test/java/org/apache/flink/streaming/api/graph/StreamingJobGraphGeneratorTest.java
 ##########
 @@ -657,6 +660,117 @@ public void testNotSupportInputSelectableOperatorIfCheckpointing()
{
 		StreamingJobGraphGenerator.createJobGraph(env.getStreamGraph());
 	}
 
+	@Test
+	public void testManagedMemoryFractionForSpecifiedResourceSpec() throws Exception {
+		final ResourceSpec resource1 = ResourceSpec.newBuilder(1, 100)
+			.setOnHeapManagedMemory(new MemorySize(100))
+			.setOffHeapManagedMemory(new MemorySize(40))
+			.build();
+		final ResourceSpec resource2 = ResourceSpec.newBuilder(1, 100)
+			.setOnHeapManagedMemory(new MemorySize(300))
+			.setOffHeapManagedMemory(new MemorySize(50))
+			.build();
+		final ResourceSpec resource3 = ResourceSpec.newBuilder(1, 100)
+			.setOnHeapManagedMemory(new MemorySize(600))
+			.setOffHeapManagedMemory(new MemorySize(10))
+			.build();
+		final ResourceSpec resource4 = ResourceSpec.newBuilder(1, 100)
+			.setOnHeapManagedMemory(new MemorySize(123))
+			.setOffHeapManagedMemory(new MemorySize(456))
+			.build();
+
+		// v1, v2 are in the same slot sharing group, v3 is in a different group
+		final JobGraph jobGraph = createJobGraphForManagedMemoryFractionTest(resource1, resource2,
resource3, resource4);
+		final JobVertex vertex1 = jobGraph.getVerticesSortedTopologicallyFromSources().get(0);
+		final JobVertex vertex2 = jobGraph.getVerticesSortedTopologicallyFromSources().get(1);
+		final JobVertex vertex3 = jobGraph.getVerticesSortedTopologicallyFromSources().get(2);
+
+		final StreamConfig sourceConfig = new StreamConfig(vertex1.getConfiguration());
+		assertEquals(0.1, sourceConfig.getManagedMemoryFractionOnHeap(), 0.000001);
+		assertEquals(0.4, sourceConfig.getManagedMemoryFractionOffHeap(), 0.000001);
+
+		final StreamConfig map1Config = Iterables.getOnlyElement(
+			sourceConfig.getTransitiveChainedTaskConfigs(StreamingJobGraphGeneratorTest.class.getClassLoader()).values());
+		assertEquals(0.3, map1Config.getManagedMemoryFractionOnHeap(), 0.000001);
+		assertEquals(0.5, map1Config.getManagedMemoryFractionOffHeap(), 0.000001);
+
+		final StreamConfig map2Config = new StreamConfig(vertex2.getConfiguration());
+		assertEquals(0.6, map2Config.getManagedMemoryFractionOnHeap(), 0.000001);
+		assertEquals(0.1, map2Config.getManagedMemoryFractionOffHeap(), 0.000001);
+
+		final StreamConfig map3Config = new StreamConfig(vertex3.getConfiguration());
+		assertEquals(1.0, map3Config.getManagedMemoryFractionOnHeap(), 0.000001);
+		assertEquals(1.0, map3Config.getManagedMemoryFractionOffHeap(), 0.000001);
+	}
+
+	@Test
+	public void testManagedMemoryFractionForUnknownResourceSpec() throws Exception {
+		final ResourceSpec resource1 = ResourceSpec.UNKNOWN;
+		final ResourceSpec resource2 = ResourceSpec.UNKNOWN;
+		final ResourceSpec resource3 = ResourceSpec.UNKNOWN;
+		final ResourceSpec resource4 = ResourceSpec.UNKNOWN;
+
+		final JobGraph jobGraph = createJobGraphForManagedMemoryFractionTest(resource1, resource2,
resource3, resource4);
+		final JobVertex vertex1 = jobGraph.getVerticesSortedTopologicallyFromSources().get(0);
+		final JobVertex vertex2 = jobGraph.getVerticesSortedTopologicallyFromSources().get(1);
+		final JobVertex vertex3 = jobGraph.getVerticesSortedTopologicallyFromSources().get(2);
+
+		final StreamConfig sourceConfig = new StreamConfig(vertex1.getConfiguration());
+		assertEquals(1.0 / 3, sourceConfig.getManagedMemoryFractionOnHeap(), 0.000001);
+		assertEquals(1.0 / 3, sourceConfig.getManagedMemoryFractionOffHeap(), 0.000001);
+
+		final StreamConfig map1Config = Iterables.getOnlyElement(
+			sourceConfig.getTransitiveChainedTaskConfigs(StreamingJobGraphGeneratorTest.class.getClassLoader()).values());
+		assertEquals(1.0 / 3, map1Config.getManagedMemoryFractionOnHeap(), 0.000001);
+		assertEquals(1.0 / 3, map1Config.getManagedMemoryFractionOffHeap(), 0.000001);
+
+		final StreamConfig map2Config = new StreamConfig(vertex2.getConfiguration());
+		assertEquals(1.0 / 3, map2Config.getManagedMemoryFractionOnHeap(), 0.000001);
+		assertEquals(1.0 / 3, map2Config.getManagedMemoryFractionOffHeap(), 0.000001);
+
+		final StreamConfig map3Config = new StreamConfig(vertex3.getConfiguration());
+		assertEquals(1.0, map3Config.getManagedMemoryFractionOnHeap(), 0.000001);
+		assertEquals(1.0, map3Config.getManagedMemoryFractionOffHeap(), 0.000001);
+
+	}
+
+	private JobGraph createJobGraphForManagedMemoryFractionTest(
+		final ResourceSpec resource1,
+		final ResourceSpec resource2,
+		final ResourceSpec resource3,
+		final ResourceSpec resource4) throws Exception {
+
+		final Method opMethod = SingleOutputStreamOperator.class.getDeclaredMethod("setResources",
ResourceSpec.class);
 
 Review comment:
   done.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message