-
Notifications
You must be signed in to change notification settings - Fork 7.9k
zend: optimisation for zend_page_size for macos. #19494
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
Conversation
Using the kernel global vm_page_size set by the dynamic linker before the process starts.
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.
No RM objections, technical review not performed
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.
From what I see here, this seems to be accurate: https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/osfmk/mach/arm/vm_param.h#L85
@devnexen Is there some public documentation rather than just code that this works?
And does this result in a measurable improvement? |
That is the issue in general with macos, however in this case here sysconf to give you an idea then here getpagesize. So we save the whole syscall at first access basically. Normally, you would at least call getpagesize instead like with FreeBSD. |
Zend/zend.c
Outdated
@@ -1275,6 +1279,10 @@ ZEND_API size_t zend_get_page_size(void) | |||
SYSTEM_INFO system_info; | |||
GetSystemInfo(&system_info); | |||
return system_info.dwPageSize; | |||
#elif defined(__APPLE__) | |||
/* Is in fact the global vm_page_size which is a kernel global |
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.
If the purpose is to safe syscall, wouldn't it be better to cache the result like in https://github.com/apple-open-source-mirror/Libc/blob/5e566be7a7047360adfb35ffc44c6a019a854bea/gen/FreeBSD/getpagesize.c#L50-L64 for all platforms?
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.
Some of the callsites already cache it., like here. If you mean in here to me windodws/posix cases would benefit it, for mac it is just a variable.
That does not seem particularly worth it going into undocumented territory? |
fair enough. with Mac it is often like this, someone figure something out and we share amongst oss projects :) Anyhow, would calling getpagesize like for FreeBSD case suit you ? |
Zend/zend.c
Outdated
/* This returns the value obtained from | ||
* the auxv vector, avoiding a syscall. */ |
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.
Is this comment accurate for macOS? From your link https://github.com/apple-open-source-mirror/Libc/blob/5e566be7a7047360adfb35ffc44c6a019a854bea/gen/FreeBSD/sysconf.c#L296 it appears that sysconf(_SC_PAGESIZE)
just calls getpagesize()
, so we only save a single function call, not a syscall, no?
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.
yes I can correct the comment.
7f3ed3f
to
1ea4995
Compare
Using the getpagesize() call instead which saves one call.
Using the kernel global vm_page_size set by the dynamic linker before the process starts.