[PATCH] D38119: [XRay][compiler-rt] Use a hand-written circular buffer in BufferQueue

Dean Michael Berris via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 20 21:45:34 PDT 2017


dberris created this revision.

This change removes the dependency on using a std::deque<...> for the
storage of the buffers in the buffer queue. We instead implement a
fixed-size circular buffer that's resilient to exhaustion, and preserves
the semantics of the BufferQueue.

We're moving away from using std::deque<...> for two reasons:

- We want to remove dependencies on the STL for data structures.
- We want the data structure we use to not require re-allocation in the normal course of operation.

The internal implementation of the buffer queue uses heap-allocated
arrays that are initialized once when the BufferQueue is created, and
re-uses slots in the buffer array as buffers are returned in order.

We also change the lock used in the implementation to a spinlock
instead of a blocking mutex. We reason that since the release operations
now take very little time in the critical section, that a spinlock would
be appropriate.

This change is related to https://reviews.llvm.org/D38073.


https://reviews.llvm.org/D38119

Files:
  lib/xray/xray_buffer_queue.cc
  lib/xray/xray_buffer_queue.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38119.116139.patch
Type: text/x-patch
Size: 4666 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170921/00074da5/attachment.bin>


More information about the llvm-commits mailing list