Skip to content
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

[SCB-1232] make GroupExecutor configuration compatible to old version #1161

Merged
merged 1 commit into from Apr 1, 2019

Conversation

wujimin
Copy link
Contributor

@wujimin wujimin commented Mar 31, 2019

expect to work like tomcat thread pool
but jdk standard thread pool's behavior is different:

JDK standard thread pool rules:
  1.use core threads.
  2.if all core threads are busy, then queue the request.
  3.if queue is full, then create new thread util reach the limit of max threads.
  4.if queue is full, and threads count is max, then reject the request.

to do what we want, need to lock the executor several times for one task, that's too bad

so only make compatible to old version temporary

@coveralls
Copy link

coveralls commented Mar 31, 2019

Coverage Status

Coverage increased (+0.02%) to 85.726% when pulling 585edca on wujimin:group-executor-config-compatible into 002ee16 on apache:master.

"coreThreads is bigger than maxThreads, change from 25 to 10.",
collector.getEvents().get(collector.getEvents().size() - 2).getMessage());
collector.teardown();
Assert.assertEquals(10, groupExecutor.maxThreads);
Copy link
Member

Choose a reason for hiding this comment

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

Hello, in the UTs below, the groupExecutor.maxThreads is checked twice but the groupExecutor.maxThreads is not checked.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done
rewrite the compatible rule:
1.maxThreads always be the max value of (oldMax, core, newMax), if still no value, then default to 100
2.if not configured queue, then coreThreads same to maxThreads
3.if configured queue, and queue size is not max int, then coreThreads default to be 25

Copy link
Contributor

Choose a reason for hiding this comment

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

Why you keep this:
3.if configured queue, and queue size is not max int, then coreThreads default to be 25

I can't figure out the relationship between queue size and max thread size. For example, if users configure queue size to be MAX_INT/2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because of jdk thread pool rule and compatible to old version

if upgrade from old version, no queueSize configured, it will be max int, if queueSize is too big, then coreThreads different to maxThreads is no meaning
but we can not know how big is "too big"

if developers configured queueSize, we can only treat the developer know what happened, just use the existing value.

+ "1.use core threads.\n"
+ "2.if all core threads are busy, then queue the request.\n"
+ "3.if queue is full, then create new thread util reach the limit of max threads.\n"
+ "4.if queue is full, and threads count is max, then reject the request.");
Copy link
Member

Choose a reason for hiding this comment

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

Do we change the stratege to create new thread first until the limit of max threads is reached. And then queue the requests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, i have wrote the reason in the PR comment
and i will copy it to jira task comment

@wujimin wujimin force-pushed the group-executor-config-compatible branch from 9ba54eb to 585edca Compare April 1, 2019 01:03
coreThreads = maxThreads;
LOGGER.info("not configured {}, make coreThreads and maxThreads to be {}.", KEY_MAX_QUEUE_SIZE, maxThreads);
} else {
coreThreads = coreThreads <= 0 ? 25 : coreThreads;
Copy link
Contributor

Choose a reason for hiding this comment

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

This statement should be calculated before
maxThreads = Math.max(coreThreads, maxThreads);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

only developers configured a small maxThreads and big coreThreads will cause problem: ThreadPoolExecutor will throw exception in constructor

i think it's developers's duty to make a right configuration
we just handle compatible sense and default value.

@wujimin wujimin merged commit 89c0628 into apache:master Apr 1, 2019
@wujimin wujimin deleted the group-executor-config-compatible branch April 6, 2019 07:51
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.

None yet

4 participants