[PATCH] D31381: [XRay][compiler-rt] Use sanitizer_common's atomic ops

Martin Pelikán via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 26 23:48:39 PDT 2017


pelikan added a comment.

Overall, I like it.  Except for burning CPU while waiting on someone else's write(2) to (potentially) spinning rust.



================
Comment at: lib/xray/xray_buffer_queue.h:44
   std::deque<std::tuple<Buffer, bool>> Buffers;
-  std::mutex Mutex;
+  __sanitizer::SpinMutex Mutex;
   std::unordered_set<void *> OwnedBuffers;
----------------
This lock is being held over all Buffers (which may not be that bad actually).  It is also held during the only use of apply(), which calls retryingWriteAll() and therefore will take a lot of time, including passively waiting on system calls.  It would therefore make sense to use the blocking mutex here, to avoid burning CPU for potentially milliseconds.

Is there any downside to a blocking lock in this scenario?  The other ones look fine as the locks only protect very small regions of memory.


https://reviews.llvm.org/D31381





More information about the llvm-commits mailing list