Skip to content

Use common thread pool only if it is set by user#2

Closed
sazzad16 wants to merge 3 commits intoyangbodong22011:feature-introduce-jedis-thread-factoryfrom
sazzad16:yb-jedis-thread-factory-2
Closed

Use common thread pool only if it is set by user#2
sazzad16 wants to merge 3 commits intoyangbodong22011:feature-introduce-jedis-thread-factoryfrom
sazzad16:yb-jedis-thread-factory-2

Conversation

@sazzad16
Copy link
Copy Markdown

No description provided.

}
}

private ExecutorService getThreadPool() {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Do you want the user to call createAndUseDefaultThreadPool to enable the thread pool? Before again, Executors.newFixedThreadPool(MULTI_NODE_PIPELINE_SYNC_WORKERS) is still used here, and, I don't think newFixedThreadPool is needed, we already have thread pool with custom parameters. Just define it as static.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I want to keep the current behavior as the default behavior just so a large[1] pipeline doesn't cause many other pipelines to be waiting for a long time.

[1] with many connections (master nodes) and many commands to each node.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

[1] with many connections (master nodes) and many commands to each node.

In this case users should use setThreadPool to set it themselves.

The time to create and destroy FixedThreadPool each time will be longer than the execution pipeline (the operating system needs to call multiple system calls to create and destroy threads)

*/
public class JedisThreadPoolBuilder {
private static final Logger log = LoggerFactory.getLogger(JedisThreadPoolBuilder.class);
public class MultiNodePipelineThreadPool {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

If we name it MultiNodePipelineThreadPool, it is ok at present, but when we need a XXXThreadPool next time, we have to copy the code of MultiNodePipelineThreadPool, which will make a lot of code redundant, such as PoolBuilder.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'm thinking to take the risk.

If such situations comes we can have JedisThreadPool with a name to thread pool map. I'm trying to avoid more complex implementation right now.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can't agree with your point of view. This does not introduce complexity, just add two tool classes JedisThreadFactoryBuilder and JedisThreadPoolBuilder (putting it in the util directory also ok), and then customize the thread pool where needed.

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.

2 participants