-
Notifications
You must be signed in to change notification settings - Fork 88
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
Basic Mac OSX support #13
Basic Mac OSX support #13
Conversation
`clock_gettime` has only been available on mac since 10.12 (Sierra), so shim it on older vers. This shim is lower resolution, but that matters a lot less given that this usage only wants CLOCK_REALTIME_COARSE. It may not have precisely the same semantics about consistency, but I'm not sure how real a problem that is for this use case.
The timings here are a little cruder than the linux versions, but as with the clock_gettime shim, I'm not sure they're so far from reality as to be problematic. The I/O stats, however, are much worse. AFAICT macos has no way to get io counters equivalent to what procfs provides. The closest thing I could find would be dtrace probes, which would be ridiculously unwieldy (and I expect costly) for this use case, not to mention requiring root and a one-off SIP reconfig. I've opted for basic disk io stats from getrusage, based on (hardcoded) block size. Of course, this doesn't include network io, which is a major difference to the linux version.
Using block count from getrusage only reports non-cached disk IO, which is nothing like what the linux impl reports. Short of using dtrace, I can't find anything in macos that does the same, so it's better to not even pretend.
Thanks for your contribution and for bringing php-spx to macOS world ! Micro sec. accuracy is sufficient for timing. |
Don't worry for the clock_gettime shim, it can be dropped. I will made some clean up and update README. |
Ahh, I did wonder if there was a reason why FP reporter did it's own clock check, instead of using spx_resource_stats_wall_time. That definitely makes things cleaner, thanks! |
I saw that issue #7 was marked as postponed, but since I wanted this for my own purposes I decided to have a go.
This implements the minimum possible changes to build & run on OSX/macos. Some notable points:
This was built & tested on 10.11 (El Capitan), which is the same as the travis tests. The
clock_gettime
shim is apparently not required in 10.12+ but I haven't tested it yet.