mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 13:07:52 +00:00
Bug 1541105 - Cache2 I/O thread may do excessive number of AddRef/Release calls on queued nsCOMPtr's under a lock, blocking main thread under heavy load; use nsTArray APIs allowing mere move of the elements instead, r=michal,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D25815 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
e77251af23
commit
2b587a5803
@ -562,9 +562,22 @@ void CacheIOThread::LoopOneLevel(uint32_t aLevel) {
|
||||
}
|
||||
}
|
||||
|
||||
if (returnEvents)
|
||||
mEventQueue[aLevel].InsertElementsAt(0, events.Elements() + index,
|
||||
length - index);
|
||||
if (returnEvents) {
|
||||
// This code must prevent any AddRef/Release calls on the stored COMPtrs as
|
||||
// it might be exhaustive and block the monitor's lock for an excessive
|
||||
// amout of time.
|
||||
|
||||
// 'index' points at the event that was interrupted and asked for re-run,
|
||||
// all events before have run, been nullified, and can be removed.
|
||||
events.RemoveElementsAt(0, index);
|
||||
// Move events that might have been scheduled on this queue to the tail to
|
||||
// preserve the expected per-queue FIFO order.
|
||||
if (!events.AppendElements(std::move(mEventQueue[aLevel]))) {
|
||||
MOZ_CRASH("Can't allocate memory for cache IO thread queue");
|
||||
}
|
||||
// And finally move everything back to the main queue.
|
||||
events.SwapElements(mEventQueue[aLevel]);
|
||||
}
|
||||
}
|
||||
|
||||
bool CacheIOThread::EventsPending(uint32_t aLastLevel) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user