Updates the internal representation of signals in NotificationQueue
authorTobias Ritzau <ritzau@fb.com>
Fri, 22 Apr 2016 02:04:13 +0000 (19:04 -0700)
committerFacebook Github Bot 1 <facebook-github-bot-1-bot@fb.com>
Fri, 22 Apr 2016 02:05:24 +0000 (19:05 -0700)
commit7c516d1ca152a2ec36125b9b2d15f21c584b5fdb
tree02d48fef5be8795fdbf542c042b4ec1cce2ac510
parentba7c9b403a6a3978ff4a186246f7ee1434ca77b3
Updates the internal representation of signals in NotificationQueue

Summary: The signals were represented using bytes in a pipe or using a count on an event fd (when available). This count was ever growing and caused the pipe to overflow, and in both cases you would get signals on empty queues. This diff only writes to the fd if it there are no bytes to read. Due to races there can still be multiple bytes in the pipe, but overflowing should not be possible. Instead of blindly signaling when there could be messages in the queue, the signals are now synchronized with the state of the queue so that the signals are drained when the queue is empty. This also made it possible to skip the semaphore behavior of the event fd which should improve perf.

Reviewed By: dcolascione

Differential Revision: D3198252

fb-gh-sync-id: 39e620b10c254ffcacabc4c5ac36950a215d4803
fbshipit-source-id: 39e620b10c254ffcacabc4c5ac36950a215d4803
folly/io/async/NotificationQueue.h