-
Notifications
You must be signed in to change notification settings - Fork 65
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
Use logical cpus instead of physical cpus #106
Comments
That's an interesting point. Hyperthreading offer about 30 % more power than the same core without Hyperthreading. If you launch two processes for two threads that are treated by one core, you're requiring a 200 % load while the CPU can only provide about 130 %. I suggest you to compare time taken by tests when you use more or less threads with the |
I think it’s not solely about the usage per core but also having a small queue “waiting”. The hyper threaded threads may not be as fast as a physical core but why waste a bit of cpu time when we can use it to create a thread and start testing. Then when the first thread on the core is done, there’s already one that can get our full attention and no time is wasted on garbage collection, starting a new thread and possibly fixtures. I’ll cook up some numbers :) |
When I tested with one process per core vs. two processes per core, it looked like each test process was saturating one core, so there was no free resource for another process. |
Some results from a project that I'm working which is a Symfony 3.3 project with functional tests and database fixtures. I ran these tests on a Macbook Pro (2017) with dual-core i5 (2 physical cores, 4 logical cores with HT). I wrote a script to run these tests after clearing the cache and running it once to warm the (op)cache. 2 threads: 4 threads: So yeah, that's 22.79% faster on average at least on this workload with over 90% of the tests being functional tests, requiring to bootstrap the whole application and load fixtures. I'll test this with some other projects that feature more unit tests to see if there's a difference when each test finishes a lot quicker. |
Thanks for the tests, these are good results! IIRC tests took longer time with Hyperthreading, I tested it on a quad core / 8 processes i7 2 years ago. Too bah I didn't save the results of my experiment. |
You're welcome! 👍 I've heard that for gaming it's often preferred to have HT disabled so I guess it really depends on the workload. Also I noticed that for linux you already count the logical number of CPU's by counting occurrences of So yeah, things are a bit skewed now as for all platforms you use the number of logical processors except for OSX 😄 |
Just for information, for the Windows platform, the number of logical processors is already used. |
Yes, just like for Linux 👍 It's just Mac that uses the physical processor count. |
To get the most out of CPUs with hyperthreading, use
/usr/sbin/sysctl -n hw.logicalcpu
on OSX instead of/usr/sbin/sysctl -n hw.physicalcpu
.The text was updated successfully, but these errors were encountered: