Run `encode` on Rayon when the payload is expected to be large. Small payloads stay on the async task to avoid Rayon scheduling overhead.
(is_large: bool, encode: impl FnOnce() -> T + Send + 'static)
| 1773 | /// |
| 1774 | /// Small payloads stay on the async task to avoid Rayon scheduling overhead. |
| 1775 | async fn maybe_spawn_encode<T: Send + 'static>(is_large: bool, encode: impl FnOnce() -> T + Send + 'static) -> T { |
| 1776 | if is_large { |
| 1777 | spawn_rayon(encode).await |
| 1778 | } else { |
| 1779 | encode() |
| 1780 | } |
| 1781 | } |
| 1782 | |
| 1783 | /// Measure serialization/compression time for one websocket payload. |
| 1784 | fn time_encode<T>(encode: impl FnOnce() -> (InUseSerializeBuffer, T)) -> (Duration, InUseSerializeBuffer, T) { |
no test coverage detected
searching dependent graphs…