From c5fbff01ce2b3e2d3020182891d4a22b8958f7f3 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Tue, 7 Aug 2012 16:54:00 -0700 Subject: [PATCH] Add a really optimistic fast path in receive. Gives about a 7% performance improvement in msgsend-ring-pipes --- src/libcore/pipes.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index 0d684a99cba..c72a777c0a8 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -395,6 +395,20 @@ fn try_recv(-p: recv_packet_buffered) { let p_ = p.unwrap(); let p = unsafe { &*p_ }; + + // optimistic path + match p.header.state { + full => { + let mut payload = none; + payload <-> p.payload; + p.header.state = empty; + return some(option::unwrap(payload)) + }, + terminated => return none, + _ => {} + } + + // regular path let this = rustrt::rust_get_task(); rustrt::task_clear_event_reject(this); rustrt::rust_task_ref(this);