macOS: build the unitsync target on Apple Silicon#3042
Conversation
|
unitsync doesn't do anything remotely related to CPU topology AFAIK so I think the proper thing to do would be to find how exactly this dependency is created and drop it instead. |
Add the platform pieces unitsync needs on macOS: - System/Platform/Mac/CpuTopology.cpp: implements the cpu_topology API on macOS via sysctl. Uses hw.perflevel0/1.physicalcpu to split performance vs efficiency cores on Apple Silicon (falling back to a homogeneous core count on Intel / older kernels), and reports THREAD_PIN_POLICY_NONE since macOS has no affinity pinning (scheduling locality is a QoS hint instead). - tools/unitsync/CMakeLists.txt: an APPLE branch in the per-platform source selection, pulling in the Mac CpuTopology plus the shared Linux Hardware/SharedLib/SoLib sources (the Linux ThreadSupport does not build on macOS). With this, libunitsync.dylib builds as a native arm64 library under Homebrew GCC. Part of the macOS bring-up; depends on the macOS threading and CMake-configure changes in the related PRs to compile and configure cleanly. No effect on Linux/Windows.
aa9a440 to
b68a43d
Compare
|
|
@sprunk dropping that dependency would require a refactor of the thread pool, which I'm not sure is worth it right now. Affinity setting is triggered by the Thread pool implementation so we'd need to separate it out or make it optional |
|
@sprunk given that unitsync does use threading, but doesn't require affinity, the closest it gets is counting cores, perhaps making |
|
@sprunk I've dug into this more and the only options I've seen might work involve spreading a tonne of UNITSYNC ifdef's through shared files to avoid the affinity changes coming in, or a wide ranging refactor. Specifically, a generic CPU topology for tools |
sprunk
left a comment
There was a problem hiding this comment.
Looks like the explicit multithreading is there for the initial VFS scan, keeping that is reasonable so the fix is conceptually alright. I have no clue around the topic of cpu topology though so it's probably something for @lostsquirrel1.
Move the local BitsForCount helper out of Mac/CpuTopology.cpp into a generic spring::LowBitsMask in System/BitUtils.h, per review feedback. It saturates at the type width to avoid the 1<<width shift UB.
What
Adds the platform pieces
unitsyncneeds to build on macOS:System/Platform/Mac/CpuTopology.cpp— implements thecpu_topologyAPI on macOS viasysctl. Splits performance vs efficiency cores usinghw.perflevel0/1.physicalcpuon Apple Silicon (falls back to a homogeneous core count on Intel / older kernels), and returnsTHREAD_PIN_POLICY_NONEbecause macOS has no affinity-pinning API (scheduling locality is expressed as a QoS hint instead).tools/unitsync/CMakeLists.txt— anelseif (APPLE)branch in the per-platform source selection: pulls in the MacCpuTopologyplus the shared LinuxHardware/SharedLib/SoLibsources (the LinuxThreadSupportdoesn't build on macOS).Result
libunitsync.dylibbuilds as a native arm64 library under Homebrew GCC — verified locally (filereportsMach-O 64-bit dynamically linked shared library arm64, C API exports likeGetSpringVersion/GetMapCountpresent).Notes
FindSevenZip7zz,MemPoolTypesthread-id). Each is independently correct; together they make theunitsynctarget build on Apple Silicon.APPLEbranch + a new Mac-only file).hw.perflevel0/perflevel1per earlier review feedback on the macOS PR.