mozilla / audioipc

Cubeb Audio Remoting For Gecko
10 stars 17 forks source link

Reduce per-call RPC overhead #159

Closed kinetiknz closed 2 years ago

kinetiknz commented 2 years ago

Avoid several heap allocations by converting Proxy::call to blocking. We cache a single channel on each Proxy rather than creating a new one per call. crossbeam's bounded channels perform any required heap allocations when first initialized, further avoiding allocations on each channel send/recv with the std mpsc channel.

kinetiknz commented 2 years ago

I am a bit worried about the changes in c4c03b2 since it calls lock() in every RPC call. Does that cause the performance issue?

Relative to the existing code, it's cheaper since we're avoiding creating a channel (which heap allocates) on each RPC call. Ideally, all AudioIPC's real-time critical code would be wait-free, but that's a larger process to work towards.