-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Introduction of CPU thread affinity #16971
Introduction of CPU thread affinity #16971
Conversation
a3e4f1f
to
f10829f
Compare
7ae1c03
to
e1396a3
Compare
ccaef48
to
c3c73dc
Compare
6513f4e
to
26ffacd
Compare
26ffacd
to
f266a5c
Compare
The job Click to expand the log file-------------------------- -------TEST FAILURE------- -------------------------- [INFO] Results: [INFO] [ERROR] Failures: [ERROR] ClientMapEventJournalBasicTest>AbstractEventJournalBasicTest.allowReadingWithFutureSeq:512->HazelcastTestSupport.assertOpenEventually:1108->HazelcastTestSupport.assertOpenEventually:1123 CountDownLatch failed to complete within 30 seconds, count left: 1 [INFO] [ERROR] Tests run: 27743, Failures: 1, Errors: 0, Skipped: 1001 [INFO] |
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.
I approve this as an experimental feature. For a product feature, I propose the changes I commented in the pom.xml (we discussed it in private too). Good to see this coming to make drawing conclusions from our perf tests easier 🎉
I made some comments on minor things (mostly logging).
hazelcast/src/main/java/com/hazelcast/internal/networking/nio/NioNetworking.java
Outdated
Show resolved
Hide resolved
hazelcast/src/main/java/com/hazelcast/internal/util/ThreadAffinity.java
Outdated
Show resolved
Hide resolved
hazelcast/src/main/java/com/hazelcast/internal/util/ThreadAffinity.java
Outdated
Show resolved
Hide resolved
hazelcast/src/main/java/com/hazelcast/internal/util/executor/HazelcastManagedThread.java
Outdated
Show resolved
Hide resolved
new ThreadAffinity("10,"); | ||
} | ||
|
||
@Test(expected = ThreadAffinity.InvalidAffinitySyntaxException.class) |
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.
Would make sense to add a test for negative numbers too. Both for groups and thread count.
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.
Negative integers are not parsed by the parser.
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.
Shouldn't we get an InvalidAffinitySyntaxException
for such a setting?
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.
You will. Check the syntax for an integer. it will expect 1 digit followed by zero or more digits. If it sees a '-', it won't recognize it and you get a syntax error.
8530ed1
to
0e98042
Compare
0e98042
to
a7e7def
Compare
Provides CPU thread affinity.
So certain threads can have affinity for particular cpu's.
Server
Client
If you don't configure affinity for a category of threads, it means they can run on any CPU.
This gives a lot better control on latency and provides better throughput. The number of threads configured in the affinity settings overrides the number of threads that have been configured explicitly.
It matters a lot on which NUMA node the IO threads are. It can make performance very bad, but also very good. More research is needed.
For the time being this will not be a public feature. We can use it internally to exclude certain problems like threads moving over CPUS and control NUMA locality of memory.
When using the affinity syntax it is important to realize that it also includes the number of threads. So it will override the corresponding thread count.
The affinity syntax is as follows:
1,2,3,4
: We get 1 thread on CPU1, one thread on CPU2 etc. In total there are 4 threads configured which will each run on a different CPU.1-4
: this is a shortcut for the above syntax.[1-4]
: this is a group. This will give 4 threads and each thread can run on CPU's 1-4.[1-4]:2
: this is also group but with 2 threads that can run over CPUS 1-4.You can also make combinations
1,3,5-8,[10-20]:2,[31,41]:5
It is important to realize that
3-4
is something else than[3-4]
. The first configuration will give you 1 thread assigned to CPU 3 and another to CPU 4. The second configuration will give you 2 threads that both can run on CPUS 3 and 4.If you have the following CPU NUMA node mapping:
0-19
on NUMA node 020-39
on NUMA node 1You could configure 20 threads on NUMA node 0 and 20 threads on NUMA node 2 like this:
[0-19],[20-39]
.If you want to see the mapping, run
numactl --hardware
Example from a dual socket machine:
If you want to confine the partition threads to the NUMA nodes for the above configuration, you would use:
The affinity properties can only be set from the command line. E.g.
A few warnings:
[from-to]:threadcount
You need to following jars on your classpath:
If you are using the Simulator, you don't need to do anything extra since Simulator has these on the classpath.
In the System.out you will find information if the affinity has been picked up correctly. E.g.