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

[wip] show number of CPU cores in node list #27662

Closed
wants to merge 2 commits into from

Conversation

vilterp
Copy link
Contributor

@vilterp vilterp commented Jul 18, 2018

image

Also, there might be a better way to do this than saving it in NodeSummary every ten seconds (i.e. just on the RPC's codepath). Thoughts, @mrtracy?

TODOs:

  • design work to figure out how / where best to show this (cc @josueeee)

@vilterp vilterp requested review from a team July 18, 2018 00:32
@cockroach-teamcity
Copy link
Member

This change is Reviewable

}
for _, cpuInfo := range cpuInfos {
// TODO(vilterp): figure out a more robust way of accounting for hyperthreading than `*2`
numCores += cpuInfo.Cores * 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.

logical_cores = physical_cores*2 seems to be the rule for Intel (according to https://en.wikipedia.org/wiki/Hyper-threading, and it works on my laptop), but may not be the case for e.g. AMD. Not sure how best to handle this.

Copy link
Contributor

@bdarnell bdarnell left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/server/status/recorder.go, line 498 at r2 (raw file):

Previously, vilterp (Pete Vilter) wrote…

logical_cores = physical_cores*2 seems to be the rule for Intel (according to https://en.wikipedia.org/wiki/Hyper-threading, and it works on my laptop), but may not be the case for e.g. AMD. Not sure how best to handle this.

If the UI says "cores", we should report the number of cores, not the number of threads. And we need to be careful about doubling things when another layer has already doubled them (trust the libraries we're using to do a better job of handling things like intel vs amd than we can)

However, the gopsutil library doesn't look like a reliable source for this information. On linux as far as I can tell, it gives you threads instead of cores (one cpuInfo object per thread, and cpuInfo.Cores is always 1). Darwin, on the other hand, returns one cpuInfo object per socket, sets cpuInfo.Cores correctly, but doesn't report threads at all. There's an open issue about it being incorrect on windows too.

@vilterp
Copy link
Contributor Author

vilterp commented Jul 19, 2018

Thanks for pointing out these problems Ben. I changed it to use https://golang.org/pkg/runtime/#NumCPU, which returns 8 on my Mac (4 cores * 2 for hyperthreading), which seems to indicate that it's returning "threads", although the Go docs say "logical CPUs".

Like the gopsutil library, the Go stdlib has has different implementations for different OSs (https://github.com/golang/go/search?p=2&q=ncpu&unscoped_q=ncpu), but I have more confidence in the reliability of something in the stdlib.

As for what to call it, "threads" may be the correct term, but without qualification I think people would probably think it's referring to how many OS threads are running, so I'm inclined to go with "Cores".

cc @couchand — yet another column to decide whether to put in :)

@vilterp vilterp requested a review from couchand July 19, 2018 22:35
Copy link
Contributor

@bdarnell bdarnell left a comment

Choose a reason for hiding this comment

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

As for what to call it, "threads" may be the correct term, but without qualification I think people would probably think it's referring to how many OS threads are running, so I'm inclined to go with "Cores".

Agreed that "threads" is confusing, but we can't call it "cores" because that has a specific, different meaning in this context. I think "CPUs" may be the best label to use here.

(And I think we do want to report CPUs/threads instead of cores - CPUs are tangible things (units of execution and scheduling), cores are just an implementation detail)

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

Pete Vilter added 2 commits July 23, 2018 15:55
Release note (admin ui change): show number of CPUs for each node on the
overview page.
@vilterp
Copy link
Contributor Author

vilterp commented Jul 23, 2018

Ok, changed it to CPUs. That does evoke a unit of execution & scheduling without getting into the implementation details; seems like the Go authors may have come to the same conclusion by calling the stdlib function NumCPU

@petermattis I know you had asked for this; do you agree on terminology?

@petermattis
Copy link
Collaborator

I know you had asked for this; do you agree on terminology?

That's a bikeshed I do not wish to paint. I'll trust the folks on this thread to choose a good color.

@vilterp
Copy link
Contributor Author

vilterp commented Aug 6, 2018

Closed in favor of #28189, so we can see a few related new metrics in the node list.

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.

4 participants