12 ms·
The cost of calling is slow. The C code itself runs at, well, C speed. So if you're writing a system in both, it's best to have the C side do a lot in each ca
by silisili 3y ago
The cost of calling is slow. The C code itself runs at, well, C speed.
So if you're writing a system in both, it's best to have the C side do a lot in each call, vs having the Go side call a lot of tiny funcs.
- kgeist 3y agoAs far as I remember, there's a lot of machinery involved to make a C call because C doesn't know anything about Go's goroutines and their resizable stacks. So the runtime has to prepare the stack accordingly every time you make a call - and it's done on a dedicated CGO thread with a traditional stack.