Skip to content

Commit c5fbff0

Browse files
committed
Add a really optimistic fast path in receive. Gives about a 7% performance improvement in msgsend-ring-pipes
1 parent bc6ba6b commit c5fbff0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/libcore/pipes.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,20 @@ fn try_recv<T: send, Tbuffer: send>(-p: recv_packet_buffered<T, Tbuffer>)
395395
{
396396
let p_ = p.unwrap();
397397
let p = unsafe { &*p_ };
398+
399+
// optimistic path
400+
match p.header.state {
401+
full => {
402+
let mut payload = none;
403+
payload <-> p.payload;
404+
p.header.state = empty;
405+
return some(option::unwrap(payload))
406+
},
407+
terminated => return none,
408+
_ => {}
409+
}
410+
411+
// regular path
398412
let this = rustrt::rust_get_task();
399413
rustrt::task_clear_event_reject(this);
400414
rustrt::rust_task_ref(this);

0 commit comments

Comments
 (0)