WIP: Split os_perf impl for macOS and BSD - #61
Draft
snake66 wants to merge 4 commits into
Draft
Conversation
Split implementation into separate source files for macOS and BSD where necessary, and consolidate the code that's common between them into a common source. - Split CPUPerformanceInterface impl for BSD and macOS, but keep the common PIMPL wrapper class. - Move SystemProcessInterface::SystemProcess to common code, implement functions to imitate relevant macOS proc.h function for the BSD's. - Drop retreiving process args for FreeBSD and NetBSD for now, this was not implemented for macOS or OpenBSD in any case. Can add it back later if it has value. - Move NetworkPerformanceInterface::NetworkPerformance to common code. Only minor adjustments via conditional sections between macOS and BSD implementation. This work is sponsored by The FreeBSD Foundation Co-authored-by: Kurt Miller <bsdkurt@gmail.com> Co-authored-by: Greg Lewis <glewis@eyesbeyond.com>
This work is sponsored by The FreeBSD Foundation
This work is sponsored by The FreeBSD Foundation
This work is sponsored by The FreeBSD Foundation
bsdkurt
approved these changes
Jun 30, 2026
bsdkurt
left a comment
Collaborator
There was a problem hiding this comment.
I've read through this a few times and it looks good to me.
Collaborator
Author
|
Thanks for the review @bsdkurt. I'll try to apply it to the upstream bsd-port PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Separate the code originally in
hotspot/os/os_perf_bsd.cppinto a separate implementation for BSD and macOS, and also refactor the BSD implementation to keep things as consistent as possible.This PR is meant for feedback, before potentially proposing it to the upstream bsd-port project. If it's not accepted by upstream, it does not make any sense to merge it as is into the battleblow repo either. Also, it this is accepted to the upstream bsd-port repo, I think it would make sense to get the macOS part of the change integrated into the upstream mainline repo, so we don't continuously have to redo the port.
The
CPUPerformanceInterface::CPUPerformanceclass is where the implementations differ the most. This class have just been split as is, and the cruft from the other implementation removed from each of them. The common PIMPL wrapper class has been moved intoos_perf_common.cpp, while the BSD and macOS implementations of the core class now are inos_perf_bsd.cppandos_perf_macos.cpprespectively.The
SystemProcessInterface::SystemProcessclass has been made into a common implementation based on the original macOS implementation, where I have implemented minimal versions of the helper functions from the macOSlibproc.h(proc_listpids()andproc_pidpath()) for FreeBSD, OpenBSD and NetBSD based on the existing BSD port.One thing to note is that since the macOS version did not implement fetching the process arguments, neither does this version currently. This affects the FreeBSD and NetBSD versions. Not sure how important this is, but if we want it back it should be relatively simple after this refactoring is done.
Apart from the
CPUPerformanceclass and theproc_pid*helpers, the remaining code has moved toos_perf_common.cpp.It passes the tests on FreeBSD and OpenBSD (- the usual timeout), but I have not yet tested to build or run the tests on NetBSD.