New issue
Advanced search Search tips

Issue 782234 link

Starred by 5 users

Issue metadata

Status: Untriaged
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Feature



Sign in to add a comment

Rethink ProxyResolverV8TracingImpl threading

Project Member Reported by mmenke@chromium.org, Nov 7 2017

Issue description

Each ProxyResolverV8TracingImpl has its own thread, which is created when initially parsing the PAC script.  When it was called directly by the network stack, on the IO thread, this made a lot of sense, since it prevented proxy script execution from blocking network traffic, IPCs, etc.

However, now the proxy resolver runs in its own service process, do we still get anything out of not running stuff on the main thread?  I believe it's currently a dedicated service process, though that may change.

Even if we decided each resolver needs its own thread (Or to use one thread for all resolvers, just not the one the service manager is running on), we could still get rid of the hops to that thread, by having mojo calls go directly to that thread.

Anyhow, not sure this is worth the effort, just thinking aloud.
 
The fact that each has its own thread right now is an implementation bug, and I am definitely in favor of fixing that. Having multiple threads right now is pointless since all the v8 resolvers share a global isolate and lock execution to that anyway, so doing so from distinct threads is pointless. That said I recall it was only 1 or 2 instances we ended up with.

So a single thread SGTM!

Re-thinking the threading beyond that depends on the clients of the newfangled network service and their expected use-case. For Chrome a single thread and V8 isolate is a good memory tradeoff. However if the network service were being used with lots of different contexts and PAC scripts and we wanted higher throughput and CPU utilization, then being able to run multiple PAC scripts in parallel could be an advantage.

As for running v8 on the thread receiving the mojo call, would that the preclude being able to run this in an in-process mode? Or do mojo services get run on a dedicated thread already?

One thing relating to robustness (will have this issue either way) is the possibility of hangs. Running the PAC script involves running user-controlled script, which may not terminate. This is something we may want to address in the service model, or accept that one caller's independent script may hose the whole service.
A mojo service would not need to receive proxy resolution calls on the service thread - it can just create another thread, and run all mojo calls there.  So regardless of whether there's one mojo serve thread, or 5 dozen, it doesn't really matter much to whatever decision we make here, just potentially adds a little complexity to startup/shutdown.

I hadn't thought at all about hangs.  I guess we already kinda have that issue, in that we could keep hanging PAC resolvers around.  THey won't hang the service, but will hang all network requests for a context until a new resolver is created, and even then, they'll continue to consume 100% CPU time.
Status: Available (was: Untriaged)
A hang today will hang all proxy resolutions (since even though we have a thread per ProxyResolverV8TracingImpl, we lock access tot he same v8 isolate). So not a new problem. Only thin I think differs is the expectation of independence when we name things a "service".

Hanging is I would say is an orthogonal problem. One approach would be to setup a watchdog timer in-process that terminates execution of the V8 isolate (although have had problems with this messing up v8 state in the past), or suicide the whole process. Or have the caller restart the service if it is unresponsive to requests.

Comment 5 by eroman@chromium.org, Nov 29 2017

Cc: amistry@chromium.org
 Issue 174807  has been merged into this issue.
Project Member

Comment 6 by sheriffbot@chromium.org, Nov 30

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Sign in to add a comment