We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Shachar Langbeheim - async & FFI - not exactly a love story - Rust Linz
Explore the challenges and solutions of async and FFI in Rust, covering topics such as thread exhaustion, context switches, and the importance of a runtime-aware interface for efficient communication between languages.
- Marshal once, keep it alive: Use a static callback or callback per object, instead of marshaling a callback every time, to reduce the cost.
- Thread exhaustion: Incorrectly managing threads can lead to exhaustion, starving the Rust side of computation.
- Context switches: Avoid unnecessary context switches by using a runtime-aware interface to communicate between languages.
- No ABI for async operations: There is no standardized interface for asynchronous operations between languages, making it difficult to bridge the gap between runtimes.
- FFI limitations: Foreign Function Interfaces (FFI) are not designed for asynchronous operations and can lead to performance issues, such as thread exhaustion and context switches.
- Unix domain sockets: Use Unix domain sockets as a generalized interface for inter-process communication between languages, which is efficient and has received significant attention.
- Async programming is complex: Asynchronous programming is complex, especially when crossing language boundaries, and requires careful management of threads, callbacks, and context switches.
- ABI for languages: An Application Programming Interface (API) is an interface between languages, and an ABI is an interface between programs.
- Runtime-aware interface: A runtime-aware interface is essential for communication between languages, especially when dealing with asynchronous operations.
- Marshaling costs: Marshal data carefully, as the cost of marshaling can be high and impact performance.
- No language has vocabulary for async operations: There is no language that has the vocabulary needed to convey the concepts of asynchronous operations, making it difficult to bridge the gap between runtimes.