You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@uniffle.apache.org by "zuston (via GitHub)" <gi...@apache.org> on 2023/09/24 09:28:31 UTC
[GitHub] [incubator-uniffle] zuston commented on a diff in pull request #1210: [#1209] improvement(server): Optimize cleanupStorageSelectionCache method in LocalStorageManager.
zuston commented on code in PR #1210:
URL: https://github.com/apache/incubator-uniffle/pull/1210#discussion_r1335151270
##########
server/src/main/java/org/apache/uniffle/server/storage/LocalStorageManager.java:
##########
@@ -301,24 +302,36 @@ public void removeResources(PurgeEvent event) {
private void cleanupStorageSelectionCache(PurgeEvent event) {
Function<String, Boolean> deleteConditionFunc = null;
+ String prefixKey = null;
if (event instanceof AppPurgeEvent) {
+ prefixKey = UnionKey.buildKey(event.getAppId());
deleteConditionFunc =
partitionUnionKey -> UnionKey.startsWith(partitionUnionKey, event.getAppId());
} else if (event instanceof ShufflePurgeEvent) {
+ assert event.getShuffleIds().size() == 1; // only one shuffleId
Review Comment:
Could you log the size and ignore the other ids, rather than `assert` ? This is harmful for a running service
##########
server/src/main/java/org/apache/uniffle/server/storage/LocalStorageManager.java:
##########
@@ -301,24 +302,36 @@ public void removeResources(PurgeEvent event) {
private void cleanupStorageSelectionCache(PurgeEvent event) {
Function<String, Boolean> deleteConditionFunc = null;
+ String prefixKey = null;
Review Comment:
Please handle the `NPE` of `perfixKey` although event always will be hit. But for the further more implementations of event, I think we should check the NPE
##########
server/src/main/java/org/apache/uniffle/server/storage/LocalStorageManager.java:
##########
@@ -301,24 +302,36 @@ public void removeResources(PurgeEvent event) {
private void cleanupStorageSelectionCache(PurgeEvent event) {
Function<String, Boolean> deleteConditionFunc = null;
+ String prefixKey = null;
if (event instanceof AppPurgeEvent) {
+ prefixKey = UnionKey.buildKey(event.getAppId());
deleteConditionFunc =
partitionUnionKey -> UnionKey.startsWith(partitionUnionKey, event.getAppId());
} else if (event instanceof ShufflePurgeEvent) {
+ assert event.getShuffleIds().size() == 1; // only one shuffleId
+ int shuffleId = event.getShuffleIds().get(0);
+ prefixKey = UnionKey.buildKey(event.getAppId(), shuffleId);
deleteConditionFunc =
- partitionUnionKey ->
- UnionKey.startsWith(partitionUnionKey, event.getAppId(), event.getShuffleIds());
+ partitionUnionKey -> UnionKey.startsWith(partitionUnionKey, event.getAppId(), shuffleId);
}
long startTime = System.currentTimeMillis();
- deleteElement(partitionsOfStorage, deleteConditionFunc);
+ deleteElement(partitionsOfStorage.tailMap(prefixKey), deleteConditionFunc);
LOG.info(
"Cleaning the storage selection cache costs: {}(ms) for event: {}",
System.currentTimeMillis() - startTime,
event);
}
private <K, V> void deleteElement(Map<K, V> map, Function<K, Boolean> deleteConditionFunc) {
Review Comment:
Could you help rename the `map` to `sortedPartitionsOfStorageMap`? If you don't mind, the comments could be added in this method. Because the deleting logic depends on the sorted map.
##########
server/src/main/java/org/apache/uniffle/server/storage/LocalStorageManager.java:
##########
@@ -301,24 +302,36 @@ public void removeResources(PurgeEvent event) {
private void cleanupStorageSelectionCache(PurgeEvent event) {
Function<String, Boolean> deleteConditionFunc = null;
+ String prefixKey = null;
if (event instanceof AppPurgeEvent) {
+ prefixKey = UnionKey.buildKey(event.getAppId());
deleteConditionFunc =
partitionUnionKey -> UnionKey.startsWith(partitionUnionKey, event.getAppId());
} else if (event instanceof ShufflePurgeEvent) {
+ assert event.getShuffleIds().size() == 1; // only one shuffleId
+ int shuffleId = event.getShuffleIds().get(0);
+ prefixKey = UnionKey.buildKey(event.getAppId(), shuffleId);
deleteConditionFunc =
- partitionUnionKey ->
- UnionKey.startsWith(partitionUnionKey, event.getAppId(), event.getShuffleIds());
+ partitionUnionKey -> UnionKey.startsWith(partitionUnionKey, event.getAppId(), shuffleId);
}
long startTime = System.currentTimeMillis();
- deleteElement(partitionsOfStorage, deleteConditionFunc);
+ deleteElement(partitionsOfStorage.tailMap(prefixKey), deleteConditionFunc);
Review Comment:
If the `perfixKey` is null, it will throw NPE
--
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: issues-unsubscribe@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org