You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/10/24 10:38:33 UTC

[GitHub] [flink] anonymouscodeholic commented on a change in pull request #13688: [FLINK-19238] Arena block size sanity

anonymouscodeholic commented on a change in pull request #13688:
URL: https://github.com/apache/flink/pull/13688#discussion_r511387433



##########
File path: flink-state-backends/flink-statebackend-rocksdb/src/test/java/org/apache/flink/contrib/streaming/state/RocksDBMemoryControllerUtilsTest.java
##########
@@ -91,10 +93,33 @@ public void testCreateSharedResourcesWithExpectedCapacity() {
 		long totalMemorySize = 2048L;
 		double writeBufferRatio = 0.5;
 		double highPriPoolRatio = 0.1;
-		RocksDBMemoryControllerUtils.allocateRocksDBSharedResources(totalMemorySize, writeBufferRatio, highPriPoolRatio);
+		RocksDBSharedResources rocksDBSharedResources = RocksDBMemoryControllerUtils.allocateRocksDBSharedResources(totalMemorySize, writeBufferRatio, highPriPoolRatio);
 		long expectedCacheCapacity = RocksDBMemoryControllerUtils.calculateActualCacheCapacity(totalMemorySize, writeBufferRatio);
 		long expectedWbmCapacity = RocksDBMemoryControllerUtils.calculateWriteBufferManagerCapacity(totalMemorySize, writeBufferRatio);
+
 		assertThat(actualCacheCapacity.get(), is(expectedCacheCapacity));
 		assertThat(actualWbmCapacity.get(), is(expectedWbmCapacity));
+		assertThat(rocksDBSharedResources.getWriteBufferManagerCapacity(), is(expectedWbmCapacity));
+	}
+
+	@Test
+	public void testCalculateRocksDBDefaultArenaBlockSize() {
+		long writeBufferSize = 64 * 1024 * 1024;
+		long expectArenaBlockSize = writeBufferSize / 8;
+		assertThat(RocksDBMemoryControllerUtils.calculateRocksDBDefaultArenaBlockSize(writeBufferSize), is(expectArenaBlockSize));
+	}
+
+	@Test
+	public void testCalculateRocksDBMutableLimit() {
+		long bufferSize = 64 * 1024 * 1024;
+		long limit = bufferSize * 7 / 8;
+		assertThat(RocksDBMemoryControllerUtils.calculateRocksDBMutableLimit(bufferSize), is(limit));
+	}
+
+	@Test
+	public void testValidateArenaBlockSize() {
+		long arenaBlockSize = 8 * 1024 * 1024;
+		assertFalse(RocksDBMemoryControllerUtils.validateArenaBlockSize(arenaBlockSize, (long) (arenaBlockSize * 0.5)));
+		assertTrue(RocksDBMemoryControllerUtils.validateArenaBlockSize(arenaBlockSize, (long) (arenaBlockSize * 1.5)));
 	}

Review comment:
       The contract for e.g. `calculateRocksDBDefaultArenaBlockSize` would be what the JavaDoc says? What a test for `calculateRocksDBDefaultArenaBlockSize` should do IMHO is to test that the method follows its documentation. If the formula changes, the JavaDoc should change and thus the test method would change too. Does this make sense?
   
   BTW, now when I look at this closer, I think there's a minor issue. In https://github.com/ververica/frocksdb/blob/49bc897d5d768026f1eb816d960c1f2383396ef4/db/column_family.cc#L200 there's the aligning that is missing from the method. Also the test should check a case when alignment is needed and where it's not needed. I'll fix this later.




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