# How are CPUs counted in ES

**URL:** <https://discuss.elastic.co/t/how-are-cpus-counted-in-es/13927>\
**Category:** Elasticsearch\
**Created:** [October 11, 2013, 5:23pm UTC](https://discuss.elastic.co/t/how-are-cpus-counted-in-es/13927 "2013-10-11T17:23:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Logan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/logan/32/59134_2.png) [@Logan](https://discuss.elastic.co/u/Logan)\
**Post date:** [October 11, 2013, 5:23pm UTC](https://discuss.elastic.co/t/how-are-cpus-counted-in-es/13927/1 "2013-10-11T17:23:36Z")

</div>

I know that the number of thread pools are calculated by ES based on the  
number of CPUs it detects. Does anyone know if ES makes a distinction  
between physical and hyperthreaded cores? In other words will ES count a 8  
core hyperthreaded CPU as 8 or 16 CPUs?

-Logan-

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [October 11, 2013, 9:24pm UTC](https://discuss.elastic.co/t/how-are-cpus-counted-in-es/13927/2 "2013-10-11T21:24:18Z")

</div>

we use this:

numCPUs = settings.getAsInt("processors", Math.min(32,  
Runtime.getRuntime().availableProcessors()));

so whatever Runtime.getRuntime().availableProcessors() return is used. I  
don't know from the top of my head if that is guaranteed to be physical, I  
would think it depends on your system and the JVM?

simon

On Friday, October 11, 2013 7:23:36 PM UTC+2, Logan Hardy wrote:

> I know that the number of thread pools are calculated by ES based on the  
> number of CPUs it detects. Does anyone know if ES makes a distinction  
> between physical and hyperthreaded cores? In other words will ES count a 8  
> core hyperthreaded CPU as 8 or 16 CPUs?
> 
> -Logan-

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [October 12, 2013, 1:02am UTC](https://discuss.elastic.co/t/how-are-cpus-counted-in-es/13927/3 "2013-10-12T01:02:46Z")

</div>

On Linux, if you use OpenJDK 7 or Oracle Java 7, the CPU cores are computed  
with a sysconf call like in C

sysconf(\_SC\_NPROCESSORS\_ONLN)

see also  
[http://www.gnu.org/software/libc/manual/html\_node/Processor-Resources.html](http://www.gnu.org/software/libc/manual/html_node/Processor-Resources.html)

This means, the currently online CPU cores are interpreted as  
"availableProcessors()" in contrast to the installed ones.

[http://hg.openjdk.java.net/jdk7/jdk7/hotspot/file/tip/src/os/linux/vm/os\_linux.cpp](http://hg.openjdk.java.net/jdk7/jdk7/hotspot/file/tip/src/os/linux/vm/os_linux.cpp)

Other JVMs, especially OpenJDK 6, have a bug and may report "1" for  
Runtime.getRuntime().availableProcessors() on chrooted environments  
(typically VMs) because they examine the /proc folder instead of using the  
sysconf call.

Jörg

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:12am UTC](https://discuss.elastic.co/t/how-are-cpus-counted-in-es/13927/4 "2017-07-06T02:12:47Z")

</div>


