cpu_cores does not work on amazon ec2 #205

Closed
opened 2021-11-20 15:21:26 +00:00 by ungleich-gitea · 5 comments

Created by: lloyd

cores="$(cat /proc/cpuinfo | grep "core id" | sort | uniq | wc -l)"

Yields incorrect results on some virtual machines. The results of this is 1 on an r3.xlarge instance, and I imagine for others too.

The issue is all cores have a core id of 0. removing uniq fixes the problem. Is there a system where cores are reported more than once? if not, could you just simplify to:

cores="$(cat /proc/cpuinfo | grep "core id" | wc -l)"
*Created by: lloyd* ``` cores="$(cat /proc/cpuinfo | grep "core id" | sort | uniq | wc -l)" ``` Yields incorrect results on some virtual machines. The results of this is `1` on an r3.xlarge instance, and I imagine for others too. The issue is all cores have a core id of 0. removing `uniq` fixes the problem. Is there a system where cores are reported more than once? if not, could you just simplify to: ``` cores="$(cat /proc/cpuinfo | grep "core id" | wc -l)" ```
ungleich-gitea added the
Stale
label 2021-11-20 15:21:26 +00:00
Author
Owner

closed

closed
Author
Owner

Created by: telmich

Good point, dheule.

@lloyd what do you think about using your suggest version and create a new global explorer "cpu_cores_all" that includes cores based on hyperthreading?

*Created by: telmich* Good point, dheule. @lloyd what do you think about using your suggest version and create a new global explorer "cpu_cores_all" that includes cores based on hyperthreading?
Author
Owner

Created by: dheule

Hello Nico,

My intention to cpu_cores was and is to reflect the real physical cores
(without hyperthreading for example).

What about to make an additional explorer for example "cpu" which don't
reflect the real cores or sockets,
means only count the number of available cpus.

This is what counting the "core id" without uniq meens.

Regrards, Daniel

2014-05-21 23:49 GMT+02:00 Nico Schottelius notifications@github.com:

Hey lloyd,

I think this will break with hyperthreading:

[13:10] artist:~% grep "core id" /proc/cpuinfo
core id : 0
core id : 0
core id : 1
core id : 1

[on my notebook]

Maybe we should change cpu_cores to the version without uniq, like you
suggest and introduce another explorer "cpu_threads".

@dheule https://github.com/dheule and @astevenhttps://github.com/astevenwhat do you think about this change? In case we go for it, I'll make a
minor version bump -> incompatible change.


Reply to this email directly or view it on GitHubhttps://github.com/telmich/cdist/issues/337#issuecomment-43818840
.

*Created by: dheule* Hello Nico, My intention to cpu_cores was and is to reflect the real physical cores (without hyperthreading for example). What about to make an additional explorer for example "cpu" which don't reflect the real cores or sockets, means only count the number of available cpus. This is what counting the "core id" without uniq meens. Regrards, Daniel 2014-05-21 23:49 GMT+02:00 Nico Schottelius notifications@github.com: > Hey lloyd, > > I think this will break with hyperthreading: > > [13:10] artist:~% grep "core id" /proc/cpuinfo > core id : 0 > core id : 0 > core id : 1 > core id : 1 > > [on my notebook] > > Maybe we should change cpu_cores to the version without uniq, like you > suggest and introduce another explorer "cpu_threads". > > @dheule https://github.com/dheule and @astevenhttps://github.com/astevenwhat do you think about this change? In case we go for it, I'll make a > minor version bump -> incompatible change. > > — > Reply to this email directly or view it on GitHubhttps://github.com/telmich/cdist/issues/337#issuecomment-43818840 > .
Author
Owner

Created by: dheule

Hello lloyd,

seems that amazone ec2 has some courious cpu architecture.
Normaly on linux, the "core id" is only the same if hyperthreads are
connected to the same physical core.

2014-05-21 11:09 GMT+02:00 Lloyd Hilaiel notifications@github.com:

cores="$(cat /proc/cpuinfo | grep "core id" | sort | uniq | wc -l)"

Yields incorrect results on some virtual machines. The results of this is
1 on an r3.xlarge instance, and I imagine for others too.

The issue is all cores have a core id of 0. removing uniq fixes the
problem. Is there a system where cores are reported more than once? if not,
could you just simplify to:

cores="$(cat /proc/cpuinfo | grep "core id" | wc -l)"


Reply to this email directly or view it on GitHubhttps://github.com/telmich/cdist/issues/337
.

*Created by: dheule* Hello lloyd, seems that amazone ec2 has some courious cpu architecture. Normaly on linux, the "core id" is only the same if hyperthreads are connected to the same physical core. 2014-05-21 11:09 GMT+02:00 Lloyd Hilaiel notifications@github.com: > cores="$(cat /proc/cpuinfo | grep "core id" | sort | uniq | wc -l)" > > Yields incorrect results on some virtual machines. The results of this is > 1 on an r3.xlarge instance, and I imagine for others too. > > The issue is all cores have a core id of 0. removing uniq fixes the > problem. Is there a system where cores are reported more than once? if not, > could you just simplify to: > > cores="$(cat /proc/cpuinfo | grep "core id" | wc -l)" > > — > Reply to this email directly or view it on GitHubhttps://github.com/telmich/cdist/issues/337 > .
Author
Owner

Created by: telmich

Hey lloyd,

I think this will break with hyperthreading:

[13:10] artist:~% grep "core id" /proc/cpuinfo
core id : 0
core id : 0
core id : 1
core id : 1

[on my notebook]

Maybe we should change cpu_cores to the version without uniq, like you suggest and introduce another explorer "cpu_threads".

@dheule and @asteven what do you think about this change? In case we go for it, I'll make a minor version bump -> incompatible change.

*Created by: telmich* Hey lloyd, I think this will break with hyperthreading: [13:10] artist:~% grep "core id" /proc/cpuinfo core id : 0 core id : 0 core id : 1 core id : 1 [on my notebook] Maybe we should change cpu_cores to the version without uniq, like you suggest and introduce another explorer "cpu_threads". @dheule and @asteven what do you think about this change? In case we go for it, I'll make a minor version bump -> incompatible change.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: ungleich-public/cdist#205
No description provided.