facebook / facebook/folly

Fast path for UnboundedQueue::try_dequeue()?

Open
#1,802 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
30.5k
Forks
5.9k
PR merge metrics
No merged PRs in 30d

Description

https://github.com/facebook/folly/blob/7613938ff11c89c50f28a2c2bc98e6df3ea15ca5/folly/concurrency/UnboundedQueue.h#L775

We're doing a tokio-like runtime that uses an UnboundedQueue as the run queue, and a common thing to do is call try_dequeue(), and go into IDLE state when it returns None. The current try_dequeue implementation will make two unnecessary calls to `steady_clock::now()`, one taking ~20ns in our environment.

So should we add a fast path to try_dequeue(), which will reduce try_dequeue latency from ~46ns to ~3ns. I'd love to contribute an PR if we should.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.