jaypipes / ghw

Go HardWare discovery/inspection library
Apache License 2.0
1.62k stars 174 forks source link

linux: refactor ProcessorCore retrieval #346

Closed jaypipes closed 1 year ago

jaypipes commented 1 year ago

Reworks the way that ProcessorCore structs are determined on Linux by breaking up the long processorsGet function into smaller functions and using standard maps for looking up Processor and logicalProcessor structs.

Removes the ProcessorCore.Index field entirely, since it was confusing and did not actually represent anything useful. Added clarity to the documentation about ProcessorCore.LogicalProcessors and how those numbers are actually the zero-based index of processors on the host and are sometimes called "thread siblings" and that zero-based index of logical processor IDs has nothing to do with the core ID.

Fixes Issue #345

ffromani commented 1 year ago

ack @jaypipes I'll be happy to have a look ASAP

jaypipes commented 1 year ago

@ffromani anything about this look faulty to you? I'd like to cut a new release with this fix in the next few days.

ffromani commented 1 year ago

@jaypipes feel free to merge if you are happy with what we are converging on https://github.com/jaypipes/ghw/pull/346#discussion_r1258228853