News for hackers. Stuff that matters.
Re:How a fix in Go 1.9 sped up our Gitaly service by 30x by dboreham on Thursday January 25, 2018 @05:44PM (#16235431)
Because decades of written material about Unix says fork() is really cool (even though it isn't)?
Re:How a fix in Go 1.9 sped up our Gitaly service by 30x by f2f on Thursday January 25, 2018 @05:56PM (#16235528)
fork was alright before other people tacked on multiples of cruft like threads and whatnot onto commercial unixes and they became mainstream. the current problem is that you don't want to have to copy all file descriptors if all you're going to do is call "exec" and reduce them to three: in, out, err.

for example, here's the caveats section from the macOS fork man page:

     There are limits to what you can do in the child process.  To be totally safe you should restrict your-
     self to only executing async-signal safe operations until such time as one of the exec functions is
     called.  All APIs, including global data symbols, in any framework or library should be assumed to be
     unsafe after a fork() unless explicitly documented to be safe or async-signal safe.  If you need to use
     these frameworks in the child process, you must exec.  In this situation it is reasonable to exec your-
     self.
That spells defeat :)

Earlier in the game, copy-on-write had to be created for the same reasons.

Re:How a fix in Go 1.9 sped up our Gitaly service by 30x by cstrahan on Friday January 26, 2018 @12:02AM (#16237145)
> the current problem is that you don't want to have to copy all file descriptors if all you're going to do is call "exec" and reduce them to three: in, out, err.

To be clear, exec does not necessarily close all but the first three fds -- by default all fds will be inherited. However, you can set the close-on-exec flag on each individual fd (in fact, that's what the Go stdlib does behind the scenes).

Search for FD_CLOEXEC in fcntl(2) and open(2) and you'll see what I'm referring to.

http://man7.org/linux/man-pages/man2/fcntl.2.html

http://man7.org/linux/man-pages/man2/open.2.html