-
Notifications
You must be signed in to change notification settings - Fork 129
Use sysctl(3) on BSD #733
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
Use sysctl(3) on BSD #733
Conversation
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.
I think we can improve the style to look more like what we do elsewhere in the code. Also, can you list which OSes you have tested already with the changes?
sysctlbyname(3) is a convenience wrapper for sysctl(3) that is implemented on FreeBSD and MacOS, but not on OpenBSD. Include sys/param.h to ensure that BSD is defined. Tests on OpenBSD: - make check - initialize a monitor node and 2 nodes - perform failover Tests on MacOS: - make check
|
Hi @eradman ; I just had a try of your branch locally on my laptop, and it fails to detect the amount of RAM properly when using your current code. I suppose the old API needs to use another MIB? - 12:23:02 43377 DEBUG pgtuning.c:85: Detected 12 CPUs and 16 GB total RAM on this server
+ 12:22:26 42248 DEBUG pgtuning.c:85: Detected 12 CPUs and 2048 MB total RAM on this serverThat's the diff when running the following command once in the master's branch, then once in your PR branch: |
Tested on - MacOS 11.4 - FreeBSD 11.4 - OpenBSD 6.9 PG_AUTOCTL_DEBUG=1 pg_autoctl do pgsetup tune --pgdata /tmp -vv
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.
This change was not nearly as easy as I thought since sysctl API has diverged between various BSD-like platforms
Other options:
- Patch this in OpenBSD ports
- Create a compatibility function sysctlbyname(3) for OpenBSD
|
I just tried it with a macOS and confirm this now works, and I think we're good with the code the way you've submitted it. I trust you have validated OpenBSD and FreeBSD variants, and intend to merge after Travis confirmed a test run. |
|
Thanks for your contribution @eradman ! |
sysctlbyname(3) is a convenience wrapper for sysctl(3) that is implemented on FreeBSD and MacOS, but not on OpenBSD.
Include
sys/param.hto ensure that BSD is defined.