6 ms·
> costs comparable to userspace function calls. You're going to have to show me on what CPU this is true on. A syscall is no where near as fast as a function c
by nwmcsween 8y ago
> costs comparable to userspace function calls.
You're going to have to show me on what CPU this is true on. A syscall is no where near as fast as a function call.
- wahern 8y agoAn indirect function call is ~50 cycles. (http://ithare.com/infographics-operation-costs-in-cpu-clock-cycles/ http://ithare.com/infographics-operation-costs-in-cpu-clock-...) The entry and exit cost of a syscall is ~150 cycles. (Source: Many Google hits--blogs, papers--show people reciting 150 cycles exactly so I assume there's a singular, primary source for this. Maybe will track down the paper later.) I'd say that's comparable. Many syscalls take much longer, but that's just because syscalls tend to be very abstract interfaces where each call performs costly operations or bookkeeping, especially on shared data structures requiring costly memory barriers. That doesn't mean the syscall interface itself is expensive. Microkernel skeptics stopped arguing syscall overhead a long time ago, and proponents are no longer defensive about it.
- nwmcsween 8y agoDirect call without args is about nearly 10 cycles on newish hardware, vdso is probably +5-10 syscall on the same CPU that returns something like the function will probably be 4-10x
- wahern 8y agoSure, but the context is relative interface and abstraction costs. Nginx running in Wasmjit in the kernel is unlikely to be making direct calls to internal kernel functions. Even if the JIT and framework were capable of that, I would think that Nginx would still be calling through an abstraction framework that provides proper read/recv semantics. It would be the sum of those intermediate calls until reaching the same point in the kernel that you'd want to compare.