-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Introduce thread pool for multi node pipeline #3333
base: master
Are you sure you want to change the base?
Introduce thread pool for multi node pipeline #3333
Conversation
e15af9d
to
a88203e
Compare
|
Previously, every time a new MultiNodePipelineBase was created, an Executor would be created and destroyed immediately after use (very resource-intensive) So I made it a static object, created by default, but if not used, no thread will be created (just a partial memory footprint)
I don't tend to add such options. Another way is: We only add the setExecutorService interface, and the executorService is null by default. When the user does not set it through setExecutorService, it will be executed serially, as before; when the user sets the executor, it will be executed through the executor. |
* Provide an interface for users to set executors themselves. | ||
* @param executor the executor | ||
*/ | ||
public static void setExecutorService(ExecutorService executor) { |
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.
IMO, I suggest that it is better to supply this parameter directly to the constructor method rather than the setter method. : )
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.
@dengliming This is set once, works every time approach :)
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.
IMO, I suggest that it is better to supply this parameter directly to the constructor method rather than the setter method. : )
We need to pass the executor when new JedisCluster
or new JedisSharding
, and need a clear name to avoid misunderstanding by users, and there are many modifications(JedisCluster->ClusterPipeline->MultiNodePipelineBase).
But the benefit is that we can create the executor lazily, if the user passes it, we use it; otherwise, we can create a static object.
But I personally prefer the current code, and it is one-time and clear to set directly through the MultiNodePipelineBase#setExecutorService
interface (About cost: there is only a part of memory usage, if the user is not using it, no thread will be created).
30a3440
to
087ede6
Compare
…3331) * Obtain multiple pipelines concurrently. high performance improvement Signed-off-by: c00603587 <[email protected]> * execute countDown regardless of whether the above program is abnormal, otherwise the await cannot be released Signed-off-by: c00603587 <[email protected]> * Update src/main/java/redis/clients/jedis/MultiNodePipelineBase.java Co-authored-by: M Sazzadul Hoque <[email protected]> * set default sync workers to 3 Signed-off-by: c00603587 <[email protected]> * remove unused import package Signed-off-by: c00603587 <[email protected]> * modify the muti node pipeline sync workers --------- Signed-off-by: c00603587 <[email protected]> Co-authored-by: c00603587 <[email protected]> Co-authored-by: M Sazzadul Hoque <[email protected]>
087ede6
to
44713b7
Compare
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## master #3333 +/- ##
============================================
- Coverage 71.15% 71.08% -0.07%
- Complexity 4763 4774 +11
============================================
Files 278 280 +2
Lines 15014 15111 +97
Branches 1057 1065 +8
============================================
+ Hits 10683 10742 +59
- Misses 3864 3891 +27
- Partials 467 478 +11
☔ View full report in Codecov by Sentry. |
@sazzad16 commented. |
73e6265
to
03778be
Compare
@yangbodong22011 @sazzad16, we have a down-stream fork of Jedis exactly for the missing capability of re-using the thread pool. The PR seems in good shape and there are no pending comments from what I see, can you share what is preventing it from being merged? Thanks! |
@asolimando We both agreed on the solution but couldn't agree on what should be the default behavior. There were no one else for the tie-break. So this PR got stuck. |
Thanks for your reply, when you say default behavior you mean if we need to add a new constructor so that we always pass the executor, or if we rely on the In our downstream version of this patch we went for the additional parameter in the constructor wherever needed, but honestly I wouldn't mind if the current patch goes in as-is and we rework our code to set the executor via |
@sazzad16 @asolimando if you all agree with this change, I can revise this PR. |
I would love to see this functionality eventually merged upstream because I noticed performance issues with |
Apologies for the continued unsolicited feedback but because the choice of default behavior here does seem to have major performance implications, I am going to offer it anyway: I would argue that the most reasonable default behavior is to not try to perform the connection reads in parallel AT ALL. The original code attempts to do this by creating a thread pool for every call to |
This PR mainly includes the following changes:
setExecutorService
.