LuciferYang commented on a change in pull request #33848:
URL: https://github.com/apache/spark/pull/33848#discussion_r696418942
##########
File path:
common/network-shuffle/src/test/java/org/apache/spark/network/shuffle/ExternalShuffleBlockResolverSuite.java
##########
@@ -110,6 +118,48 @@ public void testSortShuffleBlocks() throws IOException {
}
}
+ @Test
+ public void testShuffleIndexCacheEvictionBehavior() throws IOException,
ExecutionException {
+ Map<String, String> config = new HashMap<>();
+ String indexCacheSize = "8192m";
+ config.put("spark.shuffle.service.index.cache.size", indexCacheSize);
+ TransportConf transportConf = new TransportConf("shuffle", new
MapConfigProvider(config));
+ ExternalShuffleBlockResolver resolver = new
ExternalShuffleBlockResolver(transportConf, null);
+ resolver.registerExecutor("app0", "exec0",
dataContext.createExecutorInfo(SORT_MANAGER));
+
+ LoadingCache<File, ShuffleIndexInformation> shuffleIndexCache =
resolver.shuffleIndexCache;
+
+ // 8g -> 8589934592 bytes
+ long maximumWeight = JavaUtils.byteStringAsBytes(indexCacheSize);
+ int unitSize = 1048575;
+ // CacheBuilder.DEFAULT_CONCURRENCY_LEVEL
+ int concurrencyLevel = 4;
+ int totalGetCount = 16384;
+ // maxCacheCount is 8192
+ long maxCacheCount = maximumWeight / concurrencyLevel / unitSize *
concurrencyLevel;
+ for (int i = 0; i < totalGetCount; i++) {
+ File indexFile = new File("shuffle_" + 0 + "_" + i + "_0.index");
+ ShuffleIndexInformation indexInfo =
Mockito.mock(ShuffleIndexInformation.class);
+ Mockito.when(indexInfo.getSize()).thenReturn(unitSize);
+ shuffleIndexCache.get(indexFile, () -> indexInfo);
Review comment:
Not easy to mock the init behavior of ShuffleIndexInformation, so there
re-write CacheLoader.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]