2
# User Paul Adenot <paul@paul.cx>
4
# Node ID decb3b5cc1c53429c4d139df0ace951eb66fbdef
5
# Parent fcdd73fc3355ed8b29794b78159e4484c7b20f70
6
Bug 1649691 - Make static assert less strict in MPSCQueue.h. r=achronop
8
Differential Revision: https://phabricator.services.mozilla.com/D81818
10
diff --git a/dom/media/AsyncLogger.h b/dom/media/AsyncLogger.h
11
--- a/dom/media/AsyncLogger.h
12
+++ b/dom/media/AsyncLogger.h
13
@@ -79,16 +79,25 @@ class AsyncLogger {
14
// A trace payload can be either:
15
// - Begin - this marks the beginning of a temporal region
16
// - End - this marks the end of a temporal region
17
// - Complete - this is a timestamp and a length, forming complete a
23
+ // The goal here is to make it easy on the allocator. We pack a pointer in the
24
+ // message struct, and we still want to do power of two allocations to
25
+ // minimize allocator slop.
26
+#if !(defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID) && \
27
+ (defined(__arm__) || defined(__aarch64__)))
28
+ static_assert(sizeof(MPSCQueue<TracePayload>::Message) <= PAYLOAD_TOTAL_SIZE,
29
+ "MPSCQueue internal allocations too big.");
31
// aLogModuleName is the name of the MOZ_LOG module.
32
explicit AsyncLogger(const char* aLogModuleName,
33
AsyncLogger::AsyncLoggerOutputMode aMode =
34
AsyncLogger::AsyncLoggerOutputMode::PROFILER)
36
mLogModule(aLogModuleName),
39
diff --git a/dom/media/MPSCQueue.h b/dom/media/MPSCQueue.h
40
--- a/dom/media/MPSCQueue.h
41
+++ b/dom/media/MPSCQueue.h
42
@@ -12,48 +12,30 @@ namespace mozilla {
43
// - Unbounded (uses a intrinsic linked list)
44
// - Allocates on Push. Push can be called on any thread.
45
// - Deallocates on Pop. Pop MUST always be called on the same thread for the
46
// life-time of the queue.
48
// In our scenario, the producer threads are real-time, they can't block. The
49
// consummer thread runs every now and then and empties the queue to a log
52
-// Having fixed size messages and jemalloc is probably not the fastest, but
53
-// allows having a simpler design, we count on the fact that jemalloc will get
54
-// the memory from a thread-local source most of the time. We'll replace
55
-// this with a fixed-size ring buffer if this becomes an issue.
56
const size_t MPSC_MSG_RESERVERD = sizeof(std::atomic<void*>);
62
Message() { mNext.store(nullptr, std::memory_order_relaxed); }
63
Message(const Message& aMessage) = delete;
64
void operator=(const Message& aMessage) = delete;
66
std::atomic<Message*> mNext;
70
- // The goal here is to make it easy on the allocator. We pack a pointer in the
71
- // message struct, and we still want to do power of two allocations to
72
- // minimize allocator slop. The allocation size are going to be constant, so
73
- // the allocation is probably going to hit the thread local cache in jemalloc,
74
- // making it cheap and, more importantly, lock-free enough. This has been
75
- // measured to be cheap and reliable enough, but will be replaced in the
77
-#if !(defined(ANDROID) && defined(__i386__))
78
- static_assert(IsPowerOfTwo(sizeof(MPSCQueue<T>::Message)),
79
- "MPSCQueue internal allocations must have a size that is a "
83
// Creates a new MPSCQueue. Initially, the queue has a single sentinel node,
84
// pointed to by both mHead and mTail.
86
// At construction, the initial message points to nullptr (it has no
87
// successor). It is a sentinel node, that does not contain meaningful
89
: mHead(new Message()), mTail(mHead.load(std::memory_order_relaxed)) {}