summaryrefslogtreecommitdiffstats
path: root/net/proxy/proxy_service_v8.cc
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-30 22:30:49 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-30 22:30:49 +0000
commit501e2d4ea3c5d685fec8b34618a79964fe2945a7 (patch)
treea6c1251f903369a770f1adcaf99ebec972cb7b5c /net/proxy/proxy_service_v8.cc
parent616b701515db7fea8e86cf01688b8840238ecdad (diff)
downloadchromium_src-501e2d4ea3c5d685fec8b34618a79964fe2945a7.zip
chromium_src-501e2d4ea3c5d685fec8b34618a79964fe2945a7.tar.gz
chromium_src-501e2d4ea3c5d685fec8b34618a79964fe2945a7.tar.bz2
Improve performance of proxy resolver by tracing DNS dependencies.
This replaces the multi-threaded V8 proxy resolver implementation, with a faster single-threaded one. The single-threaded version uses some magic to avoid blocking on DNS dependencies, so it is able to handle more parallel requests than the multi-threaded one. Design document: https://docs.google.com/a/chromium.org/document/d/16Ij5OcVnR3s0MH4Z5XkhI9VTPoMJdaBn9rKreAmGOdE/edit This has the benefit of reducing the number of threads that Chrome uses for PAC evaluation, while at the same time speeding up proxy resolving for PAC scripts that do DNS resolving (due to better parallelism). I ran a benchmark to evaluate the effectiveness of this new approach. The benchmark simulates loading the http://www.newyorktimes.com webpage with slow DNS (where each DNS resolve takes 2 seconds), and a maximum DNS resolver parallelism of 10 requests. This webpage resolves the proxy for 221 URLs, across 40 unique hostnames. - Proxy resolving using the old multithreaded code took 24.076 seconds [*] - Proxy resolving using the new code took 8.011 seconds [*] - Without a PAC script, resolving the DNS took 8.003 seconds The new proxy resolving times (8.011s) are much closer to the theoretical best (8.003s)! [*] The PAC script I used for the test was a fairly complex script 20kb (a version of google's corp PAC script modified to always call dnsResolve(host)). I will be adding histograms in a follow-up CL, to measure how often requests need to be restarted, or fall-back to synchronous mode. BUG=119151 Review URL: https://codereview.chromium.org/11885009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179714 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/proxy_service_v8.cc')
-rw-r--r--net/proxy/proxy_service_v8.cc72
1 files changed, 5 insertions, 67 deletions
diff --git a/net/proxy/proxy_service_v8.cc b/net/proxy/proxy_service_v8.cc
index 44ae82c..d5a3dd7 100644
--- a/net/proxy/proxy_service_v8.cc
+++ b/net/proxy/proxy_service_v8.cc
@@ -5,71 +5,16 @@
#include "net/proxy/proxy_service_v8.h"
#include "base/logging.h"
-#include "net/proxy/multi_threaded_proxy_resolver.h"
#include "net/proxy/network_delegate_error_observer.h"
#include "net/proxy/proxy_resolver.h"
-#include "net/proxy/proxy_resolver_js_bindings.h"
-#include "net/proxy/proxy_resolver_v8.h"
+#include "net/proxy/proxy_resolver_v8_tracing.h"
#include "net/proxy/proxy_service.h"
-#include "net/proxy/sync_host_resolver_bridge.h"
namespace net {
-namespace {
-
-// This factory creates V8ProxyResolvers with appropriate javascript bindings.
-class ProxyResolverFactoryForV8 : public ProxyResolverFactory {
- public:
- // |async_host_resolver|, |io_loop| and |net_log| must remain
- // valid for the duration of our lifetime.
- // |async_host_resolver| will only be operated on |io_loop|.
- // TODO(willchan): remove io_loop and replace it with origin_loop.
- ProxyResolverFactoryForV8(HostResolver* async_host_resolver,
- MessageLoop* io_loop,
- base::MessageLoopProxy* origin_loop,
- NetLog* net_log,
- NetworkDelegate* network_delegate)
- : ProxyResolverFactory(true /*expects_pac_bytes*/),
- async_host_resolver_(async_host_resolver),
- io_loop_(io_loop),
- origin_loop_(origin_loop),
- net_log_(net_log),
- network_delegate_(network_delegate) {
- }
-
- virtual ProxyResolver* CreateProxyResolver() OVERRIDE {
- // Create a synchronous host resolver wrapper that operates
- // |async_host_resolver_| on |io_loop_|.
- SyncHostResolverBridge* sync_host_resolver =
- new SyncHostResolverBridge(async_host_resolver_, io_loop_);
-
- NetworkDelegateErrorObserver* error_observer =
- new NetworkDelegateErrorObserver(
- network_delegate_, origin_loop_.get());
-
- // ProxyResolverJSBindings takes ownership of |error_observer| and
- // |sync_host_resolver|.
- ProxyResolverJSBindings* js_bindings =
- ProxyResolverJSBindings::CreateDefault(
- sync_host_resolver, net_log_, error_observer);
-
- // ProxyResolverV8 takes ownership of |js_bindings|.
- return new ProxyResolverV8(js_bindings);
- }
-
- private:
- HostResolver* const async_host_resolver_;
- MessageLoop* io_loop_;
- scoped_refptr<base::MessageLoopProxy> origin_loop_;
- NetLog* net_log_;
- NetworkDelegate* network_delegate_;
-};
-
-} // namespace
// static
ProxyService* CreateProxyServiceUsingV8ProxyResolver(
ProxyConfigService* proxy_config_service,
- size_t num_pac_threads,
ProxyScriptFetcher* proxy_script_fetcher,
DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher,
HostResolver* host_resolver,
@@ -80,19 +25,12 @@ ProxyService* CreateProxyServiceUsingV8ProxyResolver(
DCHECK(dhcp_proxy_script_fetcher);
DCHECK(host_resolver);
- if (num_pac_threads == 0)
- num_pac_threads = ProxyService::kDefaultNumPacThreads;
-
- ProxyResolverFactory* sync_resolver_factory =
- new ProxyResolverFactoryForV8(
- host_resolver,
- MessageLoop::current(),
- base::MessageLoopProxy::current(),
- net_log,
- network_delegate);
+ ProxyResolverErrorObserver* error_observer =
+ new NetworkDelegateErrorObserver(
+ network_delegate, base::MessageLoopProxy::current());
ProxyResolver* proxy_resolver =
- new MultiThreadedProxyResolver(sync_resolver_factory, num_pac_threads);
+ new ProxyResolverV8Tracing(host_resolver, error_observer, net_log);
ProxyService* proxy_service =
new ProxyService(proxy_config_service, proxy_resolver, net_log);