Some interesting numbers in systems programming, possibly with references.
Treat this as a brain dump. Contributions are welcome.
Type | Size | Switch latency (order of magnitude) / cost | Notes |
---|---|---|---|
Erlang process | 309 machine words (8 Bytes * 309 on 64bit arch) | (Likely in the order of magnitude of the golang switch, possibly faster because platform is optimised for soft realtime) | Stack size is dynamic, garbage collection runs per user space thread |
Golang process | 2kB | ~170 ns | dynamically allocated |
Linux thread | ulimit -s gives me 8MiB on my machine; |
~2us for a context switch | |
Linux process creation | ~5us | ||
Linux thread creation | ~35us | ||
Linux rseq | |||
atomic operations | same as variable | 6 instructions - ~ns | hidden costs due to cache invalidation problems |
Linux futex (mutex impl) | ~100 us | This includes a context switch (still trying to stay in user space as much as possible. The bigger chunk of the time should come from the context switch itself, so probably this number and the one above for thread context switch are not consistent |