-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a hot loop in DirectExchangeClient #22039
Fix a hot loop in DirectExchangeClient #22039
Conversation
The fix changes queuedClients to LinkedHashSet, this helps with the filter condition in scheduleRequestIfNecessary. In addition two for loops are modified to become one loop on Iterator.
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
Quick note about the performance regression -- what we observed was that on larger heavily-loaded clusters (hundreds of nodes), this became a severe issue causing cluster-wide degradation in performance. We've been running this fix on all of our clusters for 9+ months now and have seen full recovery to performance before 1ef4427 |
Have sent the completed CLA form to [email protected], waiting for the request to be reviewed and approved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!. Some comments. Please ping me or re-request review when its ready
@@ -73,7 +73,7 @@ public class DirectExchangeClient | |||
private final Map<URI, HttpPageBufferClient> allClients = new ConcurrentHashMap<>(); | |||
|
|||
@GuardedBy("this") | |||
private final Deque<HttpPageBufferClient> queuedClients = new LinkedList<>(); | |||
private final LinkedHashSet<HttpPageBufferClient> queuedClients = new LinkedHashSet<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private final Set<HttpPageBufferClient> queuedClients = new LinkedHashSet<>();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -284,17 +284,22 @@ synchronized int scheduleRequestIfNecessary() | |||
long projectedBytesToBeRequested = 0; | |||
int clientCount = 0; | |||
|
|||
for (HttpPageBufferClient client : queuedClients) { | |||
Iterator<HttpPageBufferClient> queuedClientsIterator = queuedClients.iterator(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: queuedClientsIterator
-> clientIterator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -304,7 +309,7 @@ public ListenableFuture<Void> isBlocked() | |||
} | |||
|
|||
@VisibleForTesting | |||
Deque<HttpPageBufferClient> getQueuedClients() | |||
LinkedHashSet<HttpPageBufferClient> getQueuedClients() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set<HttpPageBufferClient> getQueuedClients()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Thanks @surajkn |
Description
The fix changes queuedClients to LinkedHashSet, this helps with the filter condition in scheduleRequestIfNecessary. In addition two for loops are modified to become one loop on Iterator.
Additional context and related issues
We experienced some performance regression as a result of 1ef4427 and this is an attempt to fix the same.
Release notes
( ) This is not user-visible or is docs only, and no release notes are required.
(x ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text: