Increase Stream Transport thread pool max threads

RESOLVED FIXED in Firefox 21

Status

()

Core
Networking
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: dougt, Assigned: dougt)

Tracking

Trunk
mozilla21
Points:
---

Firefox Tracking Flags

(firefox19 wontfix, firefox20 wontfix, firefox21 fixed, b2g18 fixed)

Details

Attachments

(2 attachments)

(Assignee)

Description

5 years ago
Created attachment 704750 [details]
Homescreen IO Event latency

I was investigating the wait times of events that get dispatched to the socket transport thread pool.  "Latency" is the time between the event is Dispatch()'ed and the time the event is actually Run().  Currently the socket transport thread pool is configured to have 4 threads.   That is, if you dispatch 5 events, the 5th event will be queued until one of the other 4 events is finished.   We are now using this thread pool for more than just socket IO.  For example, now ipc blob and device storage now use this threadpool for any non-main thread operations they need to do.

Launching the Homescreen on B2G results in a number of events.  The follow graph shows the events and their latency.  What is troubling is that there are some very high wait times on some of the events.

I think we need to get some numbers on what upping the default thread count to something like 20 does to application performance.  I think we also need to figure out if this is a problem for desktop.
(Assignee)

Updated

5 years ago
Summary: Increase Socket Transport thread pool max threads → Increase Stream Transport thread pool max threads
This was discussed in bug 757511 but I guess nobody got around to filing the follow-up bug, which is now this.

I think that until recently, the disk cache was the biggest/primary user of this service. I am not sure if we limited the number of threads used for any particular reason; I suspect, instead, that the limit is very old and we never measured whether increasing it would help.

The most likely negative effect of this is that it may cause disk seek overhead to increase, since there will be more concurrent disk I/O operations executing. For this reason, it seems like it would be a good idea to segregate disk- and non-disk- operations into separate pools, so that we can tune disk seek overhead independently of negative effects on consumers that are using this thread pool for non-disk activities.
OS: Mac OS X → All
Hardware: x86 → All
See Also: → bug 757511, bug 703948
(Assignee)

Comment 3

5 years ago
on my fast linux box w/ SSD, i never see any latency at all with the current configuration.
(Assignee)

Comment 4

5 years ago
Created attachment 704934 [details] [diff] [review]
patch v.1

bump the threadcount
Attachment #704934 - Flags: review?(bsmith)
Comment on attachment 704934 [details] [diff] [review]
patch v.1

Review of attachment 704934 [details] [diff] [review]:
-----------------------------------------------------------------

::: netwerk/base/src/nsStreamTransportService.cpp
@@ +445,4 @@
>      mPool->SetName(NS_LITERAL_CSTRING("StreamTrans"));
> +    mPool->SetThreadLimit(25);
> +    mPool->SetIdleThreadLimit(1);
> +    mPool->SetIdleThreadTimeout(PR_SecondsToInterval(30));

Nit: please put these lines back where they originally were (above the calls to SetName) so that the blame for this file is less insane.
Attachment #704934 - Flags: review?(bsmith) → review+
(Assignee)

Comment 6

5 years ago
Comment on attachment 704934 [details] [diff] [review]
patch v.1

The reason for the change is that I wanted to be able to see who's changing the threadpool thread limit.  If you set the name later, i can't log who's making such a change.  I suppose I can make that change later.
(Assignee)

Comment 7

5 years ago
what do you want to do about this line:

nsStreamTransportService::LowerThreadLimit()
...
    if (threadLimit == 4) {
...

Should it be also 25?  I tend to think we should just get rid of it all together.
(Assignee)

Updated

5 years ago
Flags: needinfo?(bsmith)
We could also just not piggyback on stream transport pool and make a new one for our DOM file IO.
(In reply to Doug Turner (:dougt) from comment #6)
> The reason for the change is that I wanted to be able to see who's changing
> the threadpool thread limit.  If you set the name later, i can't log who's
> making such a change.  I suppose I can make that change later.

OK. Just leave it as you have it.

(In reply to Doug Turner (:dougt) from comment #7)
> what do you want to do about this line:
> 
> nsStreamTransportService::LowerThreadLimit()
> ...
>     if (threadLimit == 4) {
> ...
> 
> Should it be also 25?  I tend to think we should just get rid of it all
> together.

It should also be 25 as you've written the patch. However, I suggest that you just backout the patch for bug 757511 that added that code, as this patch should make it unnecessary. (i.e. I agree that we should get rid of it altogether.)

(In reply to ben turner [:bent] from comment #8)
> We could also just not piggyback on stream transport pool and make a new one
> for our DOM file IO.

I think DOM file IO is a reasonable use of the stream transport service. Probably not worth changing that for B2G 1.0.

I am more concerned about the non-file-I/O uses of stream transport service. I don't think it is a good idea to use the stream transport service's threadpool for non-IO tasks.
Flags: needinfo?(bsmith)
Would it be worth making the thread pool count a pref so we can tweak it more easily?  I can imagine we might want less threads on mobile devices then desktop (how much memory do we consume per thread--do we set the stack size or use the OS's default?).  It would also allow us to more easily benchmark which value is optimal here rather than just pulling one out of a hat.
https://hg.mozilla.org/mozilla-central/rev/85c0b6224065
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla21
(Assignee)

Comment 12

5 years ago
jason - sure.  follow up material! ;)
(Assignee)

Updated

5 years ago
Attachment #704934 - Flags: approval-mozilla-b2g18?
Comment on attachment 704934 [details] [diff] [review]
patch v.1

Without information about why this needs to be uplifted, it's hard to make an approval-mozilla-b2g18 decision.  Please re-nom if you'd still like to get this in.
Attachment #704934 - Flags: approval-mozilla-b2g18? → approval-mozilla-b2g18-
Comment on attachment 704934 [details] [diff] [review]
patch v.1

Doug gave some verbal justification for uplifting and it was sufficient IMHO.
Attachment #704934 - Flags: approval-mozilla-b2g18- → approval-mozilla-b2g18+
https://hg.mozilla.org/releases/mozilla-b2g18/rev/945b0ed70929
status-b2g18: --- → fixed
status-firefox19: --- → wontfix
status-firefox20: --- → wontfix
status-firefox21: --- → fixed
You need to log in before you can comment on or make changes to this bug.