forked from sanyaade-mobiledev/chromium.src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
eroman@chromium.org
committed
Jan 30, 2013
1 parent
616b701
commit 501e2d4
Showing
51 changed files
with
2,342 additions
and
1,612 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
} |
14 changes: 14 additions & 0 deletions
14
net/data/proxy_resolver_v8_tracing_unittest/dns_during_init.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
} |
14 changes: 14 additions & 0 deletions
14
net/data/proxy_resolver_v8_tracing_unittest/global_sideffects1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; | ||
} |
18 changes: 18 additions & 0 deletions
18
net/data/proxy_resolver_v8_tracing_unittest/global_sideffects2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; | ||
} |
13 changes: 13 additions & 0 deletions
13
net/data/proxy_resolver_v8_tracing_unittest/global_sideffects3.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
15 changes: 15 additions & 0 deletions
15
net/data/proxy_resolver_v8_tracing_unittest/global_sideffects4.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function FindProxyForURL(url, host) { | ||
return "PROXY " + host + ":99"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
var g_iteration = 0; | ||
|
||
function FindProxyForURL(url, host) { | ||
g_iteration++; | ||
myIpAddress(); | ||
var ip = dnsResolve(host); | ||
return "PROXY " + ip + ':' + g_iteration; | ||
} |
13 changes: 13 additions & 0 deletions
13
net/data/proxy_resolver_v8_tracing_unittest/too_many_alerts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
13 changes: 13 additions & 0 deletions
13
net/data/proxy_resolver_v8_tracing_unittest/too_many_empty_alerts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.