Fix the performance problem of InternalResourceGroup.getActiveWorkCount#20269
Conversation
To fix the performance problem, we calculate the value in AllNode's constrctor. It is only calculated once, and then read many times. Since all the node sets are immutable, this is safe to do.
|
Overall looks good, thanks for the fix. |
swapsmagic
left a comment
There was a problem hiding this comment.
LGTM. Thanks for fixing it.
agrawaldevesh
left a comment
There was a problem hiding this comment.
Requesting changes because: (a) Does this optimization actually help in terms of reducing the cost of the expensive call or the num of its invocations. (b) If it can be done in NodeManager proper
...o-main/src/main/java/com/facebook/presto/execution/resourceGroups/InternalResourceGroup.java
Show resolved
Hide resolved
agrawaldevesh
left a comment
There was a problem hiding this comment.
Forgot to request changes in the prev round of reviews
|
@dongshengbc can you add a release note with a user facing description? Maybe something like |
Sure, how to do that? link to the instruction? |
|
should have been in the PR template when you created the PR. But basically, add it in a code block at the end of the description following the format in this example: #19814 (comment) |
During an investigation of "missing metrics" problem, we traced it back to a performance problem with
InternalResourceGroup.getActiveWorkCount.The evidences:
InternalResourceGroup.getActiveWorkCountSets.diff(Sets.diff)is 30 times slower than HashSet.size(), which should be O(1).Change
To fix the problem, we calculate the value in
AllNodes' contr once, and then read many times. Since all the node sets inAllNodesare immutable, this is safe to do.Problem
The benchmark result is here. avgt = average time.
https://gist.github.com/dongshengbc/be7eee51a4d98b0dc3363b294266424b