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
port: updated PhysicalCoreID() #2260
port: updated PhysicalCoreID() #2260
Conversation
@ajkr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you change it to __GNUC_MINOR__ >= 22
? I didn't get why not support 2.22.0 (and also __GNUC_PATCHLEVEL__
seems only defined in glibc 3+)
By the way, I profiled this code (with glibc 2.23) and it makes GetPhysicalCore() 10x faster, as the comment originally suggested. This is really useful now as I'm working on core-local stats, which will make a lot of calls to GetPhysicalCore(). Thanks for your contribution! |
@ajkr I'm happy to know that this PR makes performance improvements.
Sorry, that was a mistake from my side. I meant to include 2.22.0. Thanks for catching it.
Are you suggesting me to avoid GNUC_PATCHLEVEL completely ? Like this:
|
yup your proposed change looks good! |
@joscollin updated the pull request - view changes - changes since last import |
Summary: Updated PhysicalCoreID() to use sched_getcpu() on x86_64 for glibc >= 2.22. Added a new function named GetCPUID() that calls sched_getcpu(), to avoid repeated code. Fixed the review comments too. Signed-off-by: Jos Collin <jcollin@redhat.com>
@joscollin updated the pull request - view changes - changes since last import |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@ajkr Thanks for the approval. I hope we don't have to check for GNUC_PATCHLEVEL for glibc 3+ separately. Also, I wonder why those functions are not inside a class ? Just like C-Style code ? |
@ajkr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
shouldn't need to check patch level because everything in 3+ should have the proper support. not sure why no class. I'd guess because these functions don't need to own/operate on any data so there's not much benefit to a class (besides namespacing). |
@ajkr Could you please merge this ? I have a conflict now. |
it was merged here: a620966 |
@ajkr Usually, the merges are done to the master branch. In this case, The code in the master branch is different. That's the reason I'm getting a merge conflict. Please suggest what should I do to get rid of the merge conflict. Thanks. |
hmm seems this broke the mac build:
|
Summary:
Updated PhysicalCoreID() to use sched_getcpu() on x86_64 for glibc >= 2.22. Added a new
function named GetCPUID() that calls sched_getcpu(), to avoid repeated code. This change is done as per the comments of PR: #2230
Signed-off-by: Jos Collin jcollin@redhat.com