Closed
Bug 1468108
Opened 6 years ago
Closed 6 years ago
HttpChannelParent::OnDataAvailable can jank the main thread when NS_ReadInputStreamToBuffer blocks on a lock (for buffer stealing?)
Categories
(Core :: Networking, defect, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox62 | --- | fixed |
People
(Reporter: mstange, Assigned: baku)
References
Details
(Whiteboard: [necko-triaged])
Attachments
(1 file)
4.72 KB,
patch
|
valentin
:
review+
|
Details | Diff | Splinter Review |
See this profile: https://perfht.ml/2HFmQGW nsHttpChannel::OnDataAvailable spends all most half of its time waiting on a lock inside NS_ReadInputStreamToBuffer. Based on reading the code, I think this happening inside the writer->StealBuffer() call.
Comment 1•6 years ago
|
||
Andrea, you appear to have written some of this code. Any idea how we should approach this?
Flags: needinfo?(amarchesini)
Reporter | ||
Updated•6 years ago
|
Whiteboard: [qf]
Assignee | ||
Comment 2•6 years ago
|
||
(In reply to Valentin Gosu [:valentin] from comment #1) > Andrea, you appear to have written some of this code. Any idea how we should > approach this? Yes, I wrote this code, and I suspect the lock doesn't happen in writer->StealBuffer() but, more likely here: https://searchfox.org/mozilla-central/source/netwerk/base/nsNetUtil.cpp#1658-1664 Here we have monitor.wait() because the reading of the stream happens on a IO thread, and the main-thread needs to wait the ending of that operation in order to return the content as a string. Something we can do to improve this code is here: https://searchfox.org/mozilla-central/source/netwerk/base/nsNetUtil.cpp#1700 What I would do is: 1. maybe read more than 4096 bytes. 2. try consecutive ReadSegments() instead of dispatching new runnables.
Flags: needinfo?(amarchesini)
Assignee | ||
Comment 3•6 years ago
|
||
Valentin, feedback?
Assignee: nobody → amarchesini
Attachment #8985667 -
Flags: review?(valentin.gosu)
Comment 4•6 years ago
|
||
Comment on attachment 8985667 [details] [diff] [review] stream.patch Review of attachment 8985667 [details] [diff] [review]: ----------------------------------------------------------------- Looks good to me assuming try is all green.
Attachment #8985667 -
Flags: review?(valentin.gosu) → review+
Updated•6 years ago
|
Priority: -- → P2
Whiteboard: [qf] → [qf][necko-triaged]
Pushed by amarchesini@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/61882e8a3cf3 Increase the buffer size and avoid extra runnables in NS_ReadInputStreamToBuffer, r=valentin
Comment 6•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/61882e8a3cf3
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla62
Updated•2 years ago
|
Performance Impact: --- → ?
Whiteboard: [qf][necko-triaged] → [necko-triaged]
You need to log in
before you can comment on or make changes to this bug.
Description
•