zentol commented on a change in pull request #10341: [FLINK-14974][runtime]
Calculate managed memory fractions with BigDecimal and round down it properly
URL: https://github.com/apache/flink/pull/10341#discussion_r351862080
##########
File path:
flink-streaming-java/src/test/java/org/apache/flink/streaming/api/graph/StreamingJobGraphGeneratorTest.java
##########
@@ -680,17 +683,31 @@ public void
testManagedMemoryFractionForSpecifiedResourceSpec() throws Exception
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);
+ assertEquals(100.0 / 1100,
sourceConfig.getManagedMemoryFractionOnHeap(), 0.000001);
+ assertEquals(40.0 / 110,
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);
+ assertEquals(300.0 / 1100,
map1Config.getManagedMemoryFractionOnHeap(), 0.000001);
+ assertEquals(60.0 / 110,
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);
+ assertEquals(700.0 / 1100,
map2Config.getManagedMemoryFractionOnHeap(), 0.000001);
+ assertEquals(10.0 / 110,
map2Config.getManagedMemoryFractionOffHeap(), 0.000001);
+
+ final double remainingFractionOnHeap = BigDecimal.ONE
+
.subtract(BigDecimal.valueOf(sourceConfig.getManagedMemoryFractionOnHeap()))
Review comment:
intuitively I expected us to add the fractions here. doing it via
subtraction seems like a roundabout way of doing 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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services