Skip to content

[#1209] improvement(server): Optimize cleanupStorageSelectionCache method in LocalStorageManager. - #1210

Merged
zuston merged 3 commits into
apache:masterfrom
zhuyaogai:cleanup_storage_selection_cache_optimization
Sep 25, 2023
Merged

[#1209] improvement(server): Optimize cleanupStorageSelectionCache method in LocalStorageManager.#1210
zuston merged 3 commits into
apache:masterfrom
zhuyaogai:cleanup_storage_selection_cache_optimization

Conversation

@zhuyaogai

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Optimize cleanupStorageSelectionCache method in LocalStorageManager.

Why are the changes needed?

Fix: #1209

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Exist UTs.

@codecov-commenter

codecov-commenter commented Sep 24, 2023

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 89.47368% with 2 lines in your changes missing coverage. Please review.

Project coverage is 54.87%. Comparing base (10e8e3d) to head (f7f9642).
Report is 510 commits behind head on master.

Files with missing lines Patch % Lines
...he/uniffle/server/storage/LocalStorageManager.java 89.47% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1210      +/-   ##
============================================
+ Coverage     53.68%   54.87%   +1.19%     
- Complexity     2588     2601      +13     
============================================
  Files           391      372      -19     
  Lines         22425    20126    -2299     
  Branches       1875     1887      +12     
============================================
- Hits          12038    11044     -994     
+ Misses         9682     8444    -1238     
+ Partials        705      638      -67     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zuston zuston left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch @zhuyaogai .

Overall lgtm, left some minor comments.

}
long startTime = System.currentTimeMillis();
deleteElement(partitionsOfStorage, deleteConditionFunc);
deleteElement(partitionsOfStorage.tailMap(prefixKey), deleteConditionFunc);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the perfixKey is null, it will throw NPE

deleteConditionFunc =
partitionUnionKey -> UnionKey.startsWith(partitionUnionKey, event.getAppId());
} else if (event instanceof ShufflePurgeEvent) {
assert event.getShuffleIds().size() == 1; // only one shuffleId

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you log the size and ignore the other ids, rather than assert ? This is harmful for a running service

event);
}

private <K, V> void deleteElement(Map<K, V> map, Function<K, Boolean> deleteConditionFunc) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@zhuyaogai
zhuyaogai requested a review from zuston September 24, 2023 14:00
@zhuyaogai

Copy link
Copy Markdown
Contributor Author

It is a bit weird that I can run successfully those failing unit tests locally...

@zuston

zuston commented Sep 25, 2023

Copy link
Copy Markdown
Member

It is a bit weird that I can run successfully those failing unit tests locally...

Maybe flaky tests. Do you mind submiting an issue to track and fix this ? If you want

@zuston zuston left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. waiting for all tests passed

@zuston
zuston merged commit b4adaa5 into apache:master Sep 25, 2023
@zuston

zuston commented Sep 25, 2023

Copy link
Copy Markdown
Member

Thanks @zhuyaogai Merged/

@roryqi

roryqi commented Sep 27, 2023

Copy link
Copy Markdown
Contributor

@zuston Is this a bug fix? If so, we should commit to branch 0.8, too.

@zuston

zuston commented Sep 27, 2023

Copy link
Copy Markdown
Member

@zuston Is this a bug fix? If so, we should commit to branch 0.8, too.

I think yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Improvement] Optimize cleanupStorageSelectionCache method in LocalStorageManager.

4 participants