diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-30 22:30:49 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-30 22:30:49 +0000 |
commit | 501e2d4ea3c5d685fec8b34618a79964fe2945a7 (patch) | |
tree | a6c1251f903369a770f1adcaf99ebec972cb7b5c /net/data/proxy_resolver_v8_tracing_unittest | |
parent | 616b701515db7fea8e86cf01688b8840238ecdad (diff) | |
download | chromium_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/data/proxy_resolver_v8_tracing_unittest')
11 files changed, 150 insertions, 0 deletions
diff --git a/net/data/proxy_resolver_v8_tracing_unittest/dns.js b/net/data/proxy_resolver_v8_tracing_unittest/dns.js new file mode 100644 index 0000000..fbfb74e --- /dev/null +++ b/net/data/proxy_resolver_v8_tracing_unittest/dns.js @@ -0,0 +1,31 @@ +var g_iteration = 0; + +function FindProxyForURL(url, host) { + alert('iteration: ' + g_iteration++); + + var ips = [ + myIpAddress(), + dnsResolve(''), + dnsResolveEx('host1'), + dnsResolve('host2'), + dnsResolve('host3'), + myIpAddress(), + dnsResolve('host3'), + dnsResolveEx('host1'), + myIpAddress(), + dnsResolve('host2'), + dnsResolveEx('host6'), + myIpAddressEx(), + dnsResolve('host1'), + ]; + + for (var i = 0; i < ips.length; ++i) { + // Stringize everything. + ips[i] = '' + ips[i]; + } + + var proxyHost = ips.join('-'); + proxyHost = proxyHost.replace(/[^0-9a-zA-Z.-]/g, '_'); + + return "PROXY " + proxyHost + ":99"; +} diff --git a/net/data/proxy_resolver_v8_tracing_unittest/dns_during_init.js b/net/data/proxy_resolver_v8_tracing_unittest/dns_during_init.js new file mode 100644 index 0000000..55aef52 --- /dev/null +++ b/net/data/proxy_resolver_v8_tracing_unittest/dns_during_init.js @@ -0,0 +1,14 @@ +var g_ips = [ + dnsResolve('host1'), + dnsResolve('host2') +]; + +alert('Watsup'); +alert('Watsup2'); + +function FindProxyForURL(url, host) { + // Note that host1 and host2 should not resolve using the same cache as was + // used for g_ips! + var ips = g_ips.concat([dnsResolve('host1'), dnsResolve('host2')]); + return 'PROXY ' + ips.join('-') + ':99'; +} diff --git a/net/data/proxy_resolver_v8_tracing_unittest/error.js b/net/data/proxy_resolver_v8_tracing_unittest/error.js new file mode 100644 index 0000000..83e534c --- /dev/null +++ b/net/data/proxy_resolver_v8_tracing_unittest/error.js @@ -0,0 +1,8 @@ +function FindProxyForURL(url, host) { + if (host == 'throw-an-error') { + alert('Prepare to DIE!'); + var x = null; + return x.split('-'); // Throws exception. + } + return "PROXY i-approve-this-message:42"; +} diff --git a/net/data/proxy_resolver_v8_tracing_unittest/global_sideffects1.js b/net/data/proxy_resolver_v8_tracing_unittest/global_sideffects1.js new file mode 100644 index 0000000..251af9f --- /dev/null +++ b/net/data/proxy_resolver_v8_tracing_unittest/global_sideffects1.js @@ -0,0 +1,14 @@ +var g_iteration = 0; + +function FindProxyForURL(url, host) { + g_iteration++; + + var ips = [ + dnsResolve('host1'), + dnsResolve('crazy' + g_iteration) + ]; + + alert('iteration: ' + g_iteration); + + return 'PROXY ' + ips.join('-') + ':100'; +} diff --git a/net/data/proxy_resolver_v8_tracing_unittest/global_sideffects2.js b/net/data/proxy_resolver_v8_tracing_unittest/global_sideffects2.js new file mode 100644 index 0000000..f5e5076a --- /dev/null +++ b/net/data/proxy_resolver_v8_tracing_unittest/global_sideffects2.js @@ -0,0 +1,18 @@ +var g_iteration = 0; + +function FindProxyForURL(url, host) { + g_iteration++; + + var ips; + + if (g_iteration < 3) { + ips = [ + dnsResolve('host1'), + dnsResolve('host2') + ]; + } else { + ips = [ dnsResolve('host' + g_iteration) ]; + } + + return 'PROXY ' + ips.join('-') + ':100'; +} diff --git a/net/data/proxy_resolver_v8_tracing_unittest/global_sideffects3.js b/net/data/proxy_resolver_v8_tracing_unittest/global_sideffects3.js new file mode 100644 index 0000000..0421126 --- /dev/null +++ b/net/data/proxy_resolver_v8_tracing_unittest/global_sideffects3.js @@ -0,0 +1,13 @@ +var g_iteration = 0; + +function FindProxyForURL(url, host) { + g_iteration++; + + var results = []; + for (var i = 1; i <= g_iteration; ++i) { + results.push('' + dnsResolve('host' + i)); + } + + alert('iteration: ' + g_iteration); + return 'PROXY ' + results.join('-') + ':' + g_iteration; +} diff --git a/net/data/proxy_resolver_v8_tracing_unittest/global_sideffects4.js b/net/data/proxy_resolver_v8_tracing_unittest/global_sideffects4.js new file mode 100644 index 0000000..1bfbbfd --- /dev/null +++ b/net/data/proxy_resolver_v8_tracing_unittest/global_sideffects4.js @@ -0,0 +1,15 @@ +var g_iteration = 0; + +function FindProxyForURL(url, host) { + g_iteration++; + + for (var i = 0; i < g_iteration; ++i) { + myIpAddress(); + } + + var result = '' + dnsResolve('host' + g_iteration); + result += g_iteration; + + alert('iteration: ' + g_iteration); + return 'PROXY ' + result + ':34'; +} diff --git a/net/data/proxy_resolver_v8_tracing_unittest/simple.js b/net/data/proxy_resolver_v8_tracing_unittest/simple.js new file mode 100644 index 0000000..f742081 --- /dev/null +++ b/net/data/proxy_resolver_v8_tracing_unittest/simple.js @@ -0,0 +1,3 @@ +function FindProxyForURL(url, host) { + return "PROXY " + host + ":99"; +} diff --git a/net/data/proxy_resolver_v8_tracing_unittest/simple_dns.js b/net/data/proxy_resolver_v8_tracing_unittest/simple_dns.js new file mode 100644 index 0000000..24867b0 --- /dev/null +++ b/net/data/proxy_resolver_v8_tracing_unittest/simple_dns.js @@ -0,0 +1,8 @@ +var g_iteration = 0; + +function FindProxyForURL(url, host) { + g_iteration++; + myIpAddress(); + var ip = dnsResolve(host); + return "PROXY " + ip + ':' + g_iteration; +} diff --git a/net/data/proxy_resolver_v8_tracing_unittest/too_many_alerts.js b/net/data/proxy_resolver_v8_tracing_unittest/too_many_alerts.js new file mode 100644 index 0000000..564e30e --- /dev/null +++ b/net/data/proxy_resolver_v8_tracing_unittest/too_many_alerts.js @@ -0,0 +1,13 @@ +var g_iteration = 0; + +function FindProxyForURL(url, host) { + g_iteration++; + + dnsResolve(host); + + for (var i = 0; i < 50; i++) { + alert('Gee, all these alerts are silly!'); + } + + return "PROXY foo:" + g_iteration; +} diff --git a/net/data/proxy_resolver_v8_tracing_unittest/too_many_empty_alerts.js b/net/data/proxy_resolver_v8_tracing_unittest/too_many_empty_alerts.js new file mode 100644 index 0000000..6fe85d4 --- /dev/null +++ b/net/data/proxy_resolver_v8_tracing_unittest/too_many_empty_alerts.js @@ -0,0 +1,13 @@ +var g_iteration = 0; + +function FindProxyForURL(url, host) { + g_iteration++; + + dnsResolve(host); + + for (var i = 0; i < 1000; i++) { + alert(''); + } + + return "PROXY foo:" + g_iteration; +} |