Skip to content

WIP: Split os_perf impl for macOS and BSD - #61

Draft
snake66 wants to merge 4 commits into
battleblow:bsd-portfrom
snake66:battleblow-bsd-port--split-os_perf
Draft

WIP: Split os_perf impl for macOS and BSD#61
snake66 wants to merge 4 commits into
battleblow:bsd-portfrom
snake66:battleblow-bsd-port--split-os_perf

Conversation

@snake66

@snake66 snake66 commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Separate the code originally in hotspot/os/os_perf_bsd.cpp into 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::CPUPerformance class 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 into os_perf_common.cpp, while the BSD and macOS implementations of the core class now are in os_perf_bsd.cpp and os_perf_macos.cpp respectively.

The SystemProcessInterface::SystemProcess class 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 macOS libproc.h (proc_listpids() and proc_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 CPUPerformance class and the proc_pid* helpers, the remaining code has moved to os_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.


snake66 and others added 4 commits June 12, 2026 13:54
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
@snake66
snake66 requested review from battleblow and bsdkurt June 15, 2026 10:29

@bsdkurt bsdkurt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I've read through this a few times and it looks good to me.

@snake66

snake66 commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the review @bsdkurt. I'll try to apply it to the upstream bsd-port PR.

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.

2 participants