A simple test of read performance, newsched (-O) vs. node. The server command is yes | netcat -v -v -l 127.0.0.1 2931
.
node:
var net = require('net');
var total = 0;
var client = net.connect(2931,
function() {
console.log('connected');
});
client.on('data', function(data) {
total = total + data.length;
if (total > 500000000) {
client.end();
}
});
rust:
do run_in_bare_thread {
let mut sched = ~UvEventLoop::new_scheduler();
let addr = ip4addr("127.0.0.1", 2931);
let client_task = ~do Task::new(&mut sched.stack_pool) {
do Scheduler::local |sched| {
let io = sched.event_loop.io().unwrap();
let mut stream = io.connect(addr).unwrap();
let mut buf = [0, .. 2048];
let mut total_bytes_read = 0;
while total_bytes_read < 500000000 {
let nread = stream.read(buf).unwrap();
total_bytes_read += nread;
}
stream.close();
}
};
sched.task_queue.push_back(client_task);
sched.run();
}
node:
real 0m4.426s
user 0m0.560s
sys 0m0.560s
real 0m4.495s
user 0m0.508s
sys 0m0.648s
real 0m4.455s
user 0m0.524s
sys 0m0.600s
rust:
real 0m4.384s
user 0m0.548s
sys 0m0.496s
real 0m4.346s
user 0m0.496s
sys 0m0.532s
real 0m4.378s
user 0m0.488s
sys 0m0.536s
perf:
48.86% newrt.stage1-x8 [kernel.kallsyms] [k] 0xffffffff8103ed3a ◆
3.53% newrt.stage1-x8 librustrt.so [.] upcall_call_shim_on_c_stack ▒
2.92% newrt.stage1-x8 libc-2.15.so [.] _int_free ▒
2.52% newrt.stage1-x8 libpthread-2.15.so [.] pthread_getspecific ▒
2.25% newrt.stage1-x8 libc-2.15.so [.] _int_malloc ▒
2.11% newrt.stage1-x8 libc-2.15.so [.] malloc ▒
1.52% newrt.stage1-x8 libcore-c3ca5d77d81b46c1-0.6.so [.] private::exchange_alloc::malloc::_e64b1b363cf9a6a::_06 ▒
1.18% newrt.stage1-x8 newrt.stage1-x86_64-unknown-linux-gnu [.] sched::__extensions__::meth_3991::block_running_task_and_then::_49e6b7fd24c3128::_00 ▒
1.14% newrt.stage1-x8 libcore-c3ca5d77d81b46c1-0.6.so [.] rt::rt_exchange_free::_bea361ae47773659::_06 ▒
1.13% newrt.stage1-x8 newrt.stage1-x86_64-unknown-linux-gnu [.] sched::__extensions__::meth_3953::run_cleanup_jobs::_e8adef6004193a7::_00 ▒
1.11% newrt.stage1-x8 libc-2.15.so [.] __memset_sse2 ▒
1.03% newrt.stage1-x8 librustrt.so [.] uv__read ▒
1.02% newrt.stage1-x8 librustrt.so [.] upcall_call_shim_on_rust_stack ▒
0.99% newrt.stage1-x8 librustrt.so [.] uv__io_stop ▒
0.88% newrt.stage1-x8 newrt.stage1-x86_64-unknown-linux-gnu [.] glue_drop_3578 ▒
0.88% newrt.stage1-x8 newrt.stage1-x86_64-unknown-linux-gnu [.] uvio::__extensions__::meth_5489::read::_17aaf6d4c8c3c14::_00 ▒
0.85% newrt.stage1-x8 librustrt.so [.] uv__io_poll ▒
0.82% newrt.stage1-x8 newrt.stage1-x86_64-unknown-linux-gnu [.] uv::__extensions__::read_cb::__rust_stack_shim ▒
0.81% newrt.stage1-x8 newrt.stage1-x86_64-unknown-linux-gnu [.] uvio::__extensions__::read::anon::anon::anon::expr_fn_5519 ▒
0.75% newrt.stage1-x8 librustrt.so [.] uv__io_start ▒
0.69% newrt.stage1-x8 librustrt.so [.] swap_registers ▒