Re:Show HN: voidDB – A transactional key-value DB written in...
by apatheticonion on Sunday February 02, 2025 @10:02AM
(#42909051)
Thanks! Is this also the case even Rust consumes a C library?
Re:Show HN: voidDB – A transactional key-value DB written in...
by atombender on Sunday February 02, 2025 @10:50AM
(#42909378)
No, my understanding is that Rust uses normal stacks, and it uses a classic threading model, so aside from async, calling C doesn't need to any runtime stuff.
Re:Show HN: voidDB – A transactional key-value DB written in...
by steveklabnik on Sunday February 02, 2025 @11:52AM
(#42909810)
That is correct, and was a major motivation for dropping green threads way back in 2014.
In order to interface with C code safely, Go's runtime has to jump to the system stack and do some additional setup, make the call, and then switch back. (Adding to that, if the call takes too long, this prevents other goroutines on the same OS thread from running, so the scheduler must jump in and move those goroutines to a different thread.)
All of this is expensive, though we are talking about nanoseconds, not milliseconds. Performance is mostly a problem when doing lots of very quick calls (e.g. you're writing a game engine interacting with something like OpenGL) or lots of slow calls (causing scheduler trashing).