Comment by tlrobinson

8 years ago

Or just use the operating system's `fork` system call?

There's also nailgun for Java which sounds like it works a little differently: http://martiansoftware.com/nailgun/

I guess a fork()'ed process triggers copy-on-write behavior in the kernel once the process starts running. So that's latency (the copying) you could still optimize away.

  • A common solution for web application servers ("preforking").

    The idea of keeping persistent interpreters doesn't really work for Python because the interpreter is full of state in places you'd never expect -- it's hard to reset the interpreter to a sane state after it ran some unknown program.

  • I may be wrong, but I would bet that copy-on-write of pages would be hardly visible for most workloads. Copying is quite fast when you do it in batches (4k per page).

  • You might want to measure it before you optimize it! Oftentimes I find that forks where I don't write much are quite inexpensive, with little COW action.

    • You could be right.

      Also, could it be that Intel's cache hierarchy plays some really smart tricks behind the scenes, to make this fast?