Optimize locking in ChannelEventQueue::CompleteResume
Categories
(Core :: Networking: HTTP, enhancement, P2)
Tracking
()
People
(Reporter: mayhemer, Assigned: omansfeld)
References
(Blocks 1 open bug)
Details
(Whiteboard: [necko-triaged][necko-priority-next])
Attachments
(1 file)
![]() |
Reporter | |
Comment 1•7 years ago
|
||
![]() |
Reporter | |
Comment 2•7 years ago
|
||
Mass-removing myself from cc; search for 12b9dfe4-ece3-40dc-8d23-60e179f64ac1 or any reasonable part thereof, to mass-delete these notifications (and sorry!)
Comment 4•4 years ago
|
||
A perf profile would also be useful here.
P3 for now.
Updated•3 years ago
|
Updated•2 years ago
|
Comment 5•2 years ago
|
||
Increased this to P2, since it's an easy change.
Comment 6•1 year ago
|
||
We do lots of locking.
https://searchfox.org/mozilla-central/rev/0529464f0d2981347ef581f7521ace8b7af7f7ac/netwerk/ipc/ChannelEventQueue.h#319,333,343,354
https://searchfox.org/mozilla-central/rev/0529464f0d2981347ef581f7521ace8b7af7f7ac/netwerk/ipc/ChannelEventQueue.cpp#39,46,56,81,108
Assignee | ||
Updated•11 months ago
|
Assignee | ||
Comment 7•11 months ago
|
||
Assignee | ||
Comment 8•11 months ago
|
||
Just pushed a WIP. I think the locks I removed were relatively straight forward, but I'm not sure about FlushQueue()
, because there are lots of locks in there and also stuff happening in between that doesn't need locking (see https://searchfox.org/mozilla-central/source/netwerk/ipc/ChannelEventQueue.cpp#39,46,56,81,86,103,108,113,120,125).
So in my mind it didn't make sense to put that whole function under a single lock, because then we are stopping other threads from accessing member vars for a prolonged time. I'm not sure about the performance tradeoffs here (or how to test them). That's why I called mMutex.Unlock()
before calling FlushQueue()
in MaybeFlushQueue()
, but I'm also not sure if that's the correct pattern for unlocking before scope ends.
Any input is appreciated!
Comment 9•11 months ago
•
|
||
Hey Oskar,
Just pushed a WIP. I think the locks I removed were relatively straight forward, but I'm not sure about FlushQueue(), because there are lots of locks in there and also stuff happening in between that doesn't need locking (see https://searchfox.org/mozilla-central/source/netwerk/ipc/ChannelEventQueue.cpp#39,46,56,81,86,103,108,113,120,125).
So in my mind it didn't make sense to put that whole function under a single lock, because then we are stopping other threads from accessing member vars for a prolonged time. I'm not sure about the performance tradeoffs here (or how to test them). That's why I called mMutex.Unlock() before calling FlushQueue() in MaybeFlushQueue() , but I'm also not sure if that's the correct pattern for unlocking before scope ends.
The current code (w/o your patch) minimizes critical section duration, reducing the time that other threads are blocked. However, the large number of locks introduces a higher lock acquisition overhead. An optimal solution would be to balance the duration of critical sections and the number of locks used. We need to adjust the code so that critical sections avoid executing any long-running tasks particularly the runnables in the event queue. Hence, I think we can get rid of mMutex.Unlock()
as well and further optimize FlushQueue. Apart from this I dont see any other code paths that could block for considerable duration. Kindly share if you come across more such paths.
Please run the code with the thread sanitizers in the try server. Let me know if you need more info on that.
Updated•11 months ago
|
Updated•11 months ago
|
Assignee | ||
Comment 10•11 months ago
|
||
Thanks for your input Sunil, I just put an updated patch up for review. Link to a build with thread sanitizers is also at Phabricator.
Assignee | ||
Updated•11 months ago
|
Comment 11•11 months ago
|
||
Comment 12•11 months ago
|
||
bugherder |
Updated•9 months ago
|
Description
•