5 ms·
Didn't he just say that fork turns out to be comparatively faster to the non-fork samples we get? Ie Linux spawns processes faster than Microsoft's kernels?
by theK 3mo ago
Didn't he just say that fork turns out to be comparatively faster to the non-fork samples we get? Ie Linux spawns processes faster than Microsoft's kernels?
- nvme0n1p1 3mo agoWe don't have any broadly used non-fork samples. Windows, macOS, and Linux all have fork. So the presence of fork can't be the reason for the performance difference. (Windows's fork is called ZwCreateProcess)
- dcrazy 3mo agoNtCreateProcess does not implement a forking model. It is analogous to posix_spawn.
- nvme0n1p1 3mo agoIf you pass null for the section handle, it shares pages with the calling process, thus implementing a forking model. Or at least the parts of a forking model that some people erroneously believe are responsible for performance differences.
- Someone 3mo agoMacOS has posix_spawn. See https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/posix_spawn.2.html https://developer.apple.com/library/archive/documentation/Sy... (yes, that’s an iOS man page. MacOS has the call, too, but I couldn’t find the man page online and it looks identical to me) I don’t know how they implemented it, though. Under the hood, it could do the equivalent of a fork/exec pair.
- plorkyeran 3mo agoXNU's posix_spawn implementation is not fork/exec-based. It does roughly what the API suggests it would do.
- dcrazy 3mo agoXNU is open source; here’s a link into the middle of the implementation, after it’s copied all the necessary attributes of the parent into the new process structure: https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/bsd/kern/kern_exec.c#L4039 https://github.com/apple-oss-distributions/xnu/blob/f6217f89...
- mort96 3mo agoDidn't I just say that "the problem with fork isn't really that it's slow"? It's all the other OS design choices it forces on you if you want it to be fast.
- theK 3mo agoRight, you did. I somehow misread your comment.