On 12/20/2012 05:58 PM, Michael Neumann wrote:
Hi,
I am writing a redis client [1] for rust but somehow TCP performance
seems to be veery slow. I basically just sent a string
to redis and read the response (I commented out parsing). Doing this
10_000 times takes about 4.5 seconds, while doing the same in Ruby
takes just 0.7 seconds.
Is there anything I can do about it, or is this a known issue?
Thanks for doing that test. I've been curious. Your results don't
suprise me though - std::net needs a lot of work still. I can imagine
what some of the problems are.
First, stack switching. Switching between Rust and C code has bad
performance due to bad branch prediction. Some workloads can spend 10%
of their time stalling in the stack switch.
Second, working with uv involves sending a bunch of little work units to
a dedicated uv task. This is because callbacks from uv into Rust *must
not fail* or the runtime will crash. Where typical uv code runs directly
in the event callbacks, Rust dispatches most or all of that work to
other tasks. This imposes significant context switching and locking
overhead.
On top of that, all the uv-based code is using the old,
lower-performance communication primitives in `core::oldcomm`. These
need to be converted to `core::pipes`, but there are some additional
blockers preventing it.
If anybody wants to improve std::net I can help point out the various
issues.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev