Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove /proc/cpuinfo fallback path #1921

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

Merged
merged 1 commit into from
Feb 10, 2025
Merged

Conversation

brad0
Copy link
Contributor

@brad0 brad0 commented Feb 7, 2025

AIX, WASM (fork of musl for libc) and a few others should now use the sysconf
path. /proc is not portable and cpuinfo is Linux specific. It does not work
anywhere else.

}
return num_cpus;
// Fallback, no other API exists.
return -1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be

#error Don't know how to detect CPU count for this platform?

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well the original code would build even if it would not return an appropriate value.

Depends what the intent is.

Copy link
Collaborator

@LebedevRI LebedevRI Feb 7, 2025

Choose a reason for hiding this comment

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

That's what i'm asking, yes. It does seem like a situation that should be loudly reported.
Actually, for that, we wouldn't need the return:

#else
#error Don't know how to detect CPU count for this platform
#endif
  BENCHMARK_UNREACHABLE();
}

Copy link
Member

Choose a reason for hiding this comment

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

we had this as a "soft error" only because there are so many platforms out there, and this at least returns 1 CPU in the case that we can't identify it (and logs a thing). i'm not sure we have good enough coverage yet to make it an error but if you all are confident, go for it.

Copy link
Contributor Author

@brad0 brad0 Feb 7, 2025

Choose a reason for hiding this comment

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

I guess I was figuring going with the soft error. Maybe slightly tweak the other error message to mention the need for additional OS support after this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be a loud compile-time error that can not be missed,
not a run-time error that you might not notice when packaging,
so i think it would be more safe than the current more-than-silent error...

I'd do it. Especially if we are confident that this fallback is no longer needed.

Copy link
Member

Choose a reason for hiding this comment

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

what it means is that any clients that need platform support will now find out. that may be good or bad, but basic platform support will be "return 1" within an appropriate platform define so that's easy enough.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Anyways, i've made my point. Deferring to @dmah42.

Copy link
Member

Choose a reason for hiding this comment

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

i'm happy to keep the soft error. i usually prefer hard errors but i don't really want an influx of random platforms needing support for their way to get CPU.

if we think the new version handles all cases (or should handle all cases) then we can switch it.

AIX, WASM (fork of musl for libc) and a few others should now use the sysconf
path. /proc is not portable and cpuinfo is Linux specific. It does not work
anywhere else.
@brad0 brad0 force-pushed the sysinfo_proc_cpuinfo branch from 958c0df to f9867b7 Compare February 7, 2025 01:46
@dmah42 dmah42 merged commit da9d689 into google:main Feb 10, 2025
83 of 86 checks passed
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.

3 participants