by dahfizz · 4y ago · 0 comments
> So how do you use them? Well, it turns out they’re not documented. They rely on a non-public function and flags which I had to duplicate in Firefox.
Gotta love it. You need to reverse engineer the kernel to get good performance on MacOS.
> // For information about the following undocumented flags and functions see
> // https://github.com/apple/darwin-xnu/blob/main/bsd/sys/ulock.... and
> // https://github.com/apple/darwin-libplatform/blob/main/privat...
People read through assembly to fix compiler issues, not to rationalize what the kernel is doing. You're right that this skill is still required for "perfect" optimization, but it's not really relevant when comparing kernels.
I worked on OS-Bypass HPC drivers for a pre-infiniband/ROCE NIC in the early/mid 2000s. About 90% of my time doing the driver was spent reading the kernel and IOKit sources, trying to figure out how I could use the highest performance interfaces possible in a stable way. For example, Apple really wanted you to use IOKit primitives (which used Mach IPC) to call functionality in your driver, but microbenchmarks showed it was about 50% higher latency than simple BSD ioctls from the BSD side of the kernel. That fit nicely with our driver model (which was split into OS-agnostic and OS specific code, and which used ioctls on every other *nix, and even on Windows), and got us slightly better performance.
I'm pretty sure there was some antitrust investigation over Microsoft doing the same thing: giving their own software an unfair advantage on their operating system due to the insights the Office team could gain from the kernel team.
Microsoft made a convincing argument that the relevant teams never talked to each other, and the Office developers just reverse-engineered undocumented Windows APIs, the same any other developer would have had to.
I'm gonna do a Stallman and post a reminder that webkit is an evolution of KDE's khtml. Not completely "done by apple" or even started by them.
Otherwise they would have closed it.