Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Issue 118100: Avoid doing concurrent DNS resolves of the same hostname (Closed)

Created:
11 years, 6 months ago by eroman
Modified:
9 years, 6 months ago
CC:
chromium-reviews_googlegroups.com, jar (doing other things)
Visibility:
Public.

Description

* Avoid doing concurrent DNS resolves of the same hostname in HostResolver. * Add a 1 minute cache for host resolves. * Refactor HostResolver to handle multiple requests. * Make HostResolver a dependency of URLRequestContext. operate the HostResolver in async mode for proxy resolver (bridging to IO thread). TEST=unittests BUG=13163 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=18236

Patch Set 1 #

Patch Set 2 : Add #

Patch Set 3 : Add #

Patch Set 4 : weee! #

Patch Set 5 : MOAR #

Patch Set 6 : moar #

Total comments: 1

Patch Set 7 : sync #

Patch Set 8 : sync #

Patch Set 9 : avoid #

Patch Set 10 : fix #

Patch Set 11 : fix #

Patch Set 12 : sync #

Patch Set 13 : sync #

Total comments: 73

Patch Set 14 : "Address #

Patch Set 15 : commentsfix #

Total comments: 38

Patch Set 16 : snapshot-INPROGRESS #

Patch Set 17 : snapshot-INPROGRESS #

Patch Set 18 : finish-address-willchan-comments #

Patch Set 19 : comment fix #

Total comments: 27

Patch Set 20 : Address willchan's latest comments #

Patch Set 21 : Remove 'public:' label from a struct #

Total comments: 6

Patch Set 22 : Sync to latest and address willchan's comments #

Patch Set 23 : Get compiling on mac #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+1807 lines, -197 lines) Patch
M chrome/browser/net/chrome_url_request_context.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 6 chunks +21 lines, -8 lines 0 comments Download
M chrome/browser/net/dns_global.cc View 2 chunks +0 lines, -5 lines 0 comments Download
M chrome/browser/net/dns_master.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2 chunks +4 lines, -3 lines 0 comments Download
M chrome/browser/net/dns_master_unittest.cc View 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +1 line, -1 line 0 comments Download
M net/base/address_list.h View 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +26 lines, -3 lines 2 comments Download
M net/base/address_list.cc View 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +116 lines, -2 lines 0 comments Download
A net/base/address_list_unittest.cc View 14 15 16 17 1 chunk +86 lines, -0 lines 0 comments Download
M net/base/client_socket_pool.h View 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2 chunks +4 lines, -0 lines 0 comments Download
A net/base/host_cache.h View 14 15 16 17 18 19 20 1 chunk +93 lines, -0 lines 0 comments Download
A net/base/host_cache.cc View 14 15 16 17 18 19 20 21 22 1 chunk +115 lines, -0 lines 0 comments Download
A net/base/host_cache_unittest.cc View 14 15 16 17 18 19 20 21 22 1 chunk +218 lines, -0 lines 0 comments Download
M net/base/host_resolver.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2 chunks +121 lines, -17 lines 0 comments Download
M net/base/host_resolver.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 8 chunks +309 lines, -63 lines 0 comments Download
M net/base/host_resolver_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 7 chunks +430 lines, -6 lines 0 comments Download
M net/base/ssl_client_socket_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 6 chunks +6 lines, -6 lines 0 comments Download
M net/base/ssl_test_util.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +1 line, -1 line 0 comments Download
M net/base/tcp_client_socket_pool.h View 12 13 14 15 16 17 18 19 20 21 4 chunks +10 lines, -1 line 0 comments Download
M net/base/tcp_client_socket_pool.cc View 12 13 14 15 16 17 18 19 20 21 2 chunks +4 lines, -1 line 0 comments Download
M net/base/tcp_client_socket_pool_unittest.cc View 12 13 14 15 16 17 18 19 20 21 1 chunk +7 lines, -1 line 0 comments Download
M net/base/tcp_client_socket_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +1 line, -1 line 0 comments Download
M net/base/tcp_pinger_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2 chunks +2 lines, -2 lines 0 comments Download
M net/ftp/ftp_network_layer.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +3 lines, -2 lines 0 comments Download
M net/ftp/ftp_network_layer.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +6 lines, -5 lines 0 comments Download
M net/ftp/ftp_network_session.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +6 lines, -1 line 0 comments Download
M net/ftp/ftp_network_transaction.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +2 lines, -1 line 0 comments Download
M net/ftp/ftp_network_transaction.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +1 line, -0 lines 0 comments Download
M net/http/http_cache.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 3 chunks +6 lines, -2 lines 0 comments Download
M net/http/http_cache.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2 chunks +9 lines, -4 lines 0 comments Download
M net/http/http_network_layer.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 3 chunks +9 lines, -3 lines 0 comments Download
M net/http/http_network_layer.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 3 chunks +9 lines, -4 lines 0 comments Download
M net/http/http_network_layer_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2 chunks +6 lines, -3 lines 0 comments Download
M net/http/http_network_session.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2 chunks +6 lines, -2 lines 0 comments Download
M net/http/http_network_transaction.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +0 lines, -3 lines 0 comments Download
M net/http/http_network_transaction.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +0 lines, -1 line 0 comments Download
M net/http/http_network_transaction_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2 chunks +3 lines, -1 line 0 comments Download
M net/net.gyp View 14 15 16 17 18 19 20 21 3 chunks +4 lines, -0 lines 0 comments Download
M net/proxy/proxy_resolver_perftest.cc View 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +6 lines, -1 line 0 comments Download
M net/proxy/proxy_resolver_v8.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 3 chunks +19 lines, -13 lines 0 comments Download
M net/proxy/proxy_resolver_v8.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 7 chunks +82 lines, -13 lines 0 comments Download
M net/proxy/proxy_resolver_v8_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 3 chunks +7 lines, -4 lines 0 comments Download
M net/proxy/proxy_script_fetcher_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +5 lines, -2 lines 0 comments Download
M net/proxy/proxy_service.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2 chunks +13 lines, -2 lines 0 comments Download
M net/tools/fetch/fetch_client.cc View 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2 chunks +4 lines, -2 lines 0 comments Download
M net/url_request/url_request_context.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 3 chunks +8 lines, -1 line 0 comments Download
M net/url_request/url_request_unittest.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2 chunks +8 lines, -2 lines 0 comments Download
M net/url_request/url_request_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2 chunks +5 lines, -2 lines 0 comments Download
M webkit/tools/test_shell/test_shell_request_context.cc View 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 3 chunks +5 lines, -2 lines 0 comments Download

Messages

Total messages: 24 (0 generated)
eroman
This is mostly ready for review, although still need to address Darin's comments regarding how ...
11 years, 6 months ago (2009-06-04 14:07:19 UTC) #1
eroman
http://codereview.chromium.org/118100/diff/1156/302 File net/base/address_list.cc (right): http://codereview.chromium.org/118100/diff/1156/302#newcode22 Line 22: struct addrinfo* CreateCopyOfAddrinfo(struct addrinfo* info) { ... hopefully ...
11 years, 6 months ago (2009-06-04 14:09:36 UTC) #2
eroman
Updated: no longer makes another copy of addrinfo if the ports match (will refcount the ...
11 years, 6 months ago (2009-06-05 21:09:49 UTC) #3
wtc
LGTM. http://codereview.chromium.org/118100/diff/570/602 File net/base/address_list.cc (right): http://codereview.chromium.org/118100/diff/570/602#newcode23 Line 23: struct addrinfo* copy = new addrinfo; Nit: ...
11 years, 6 months ago (2009-06-09 02:23:40 UTC) #4
willchan no longer on Chromium
Drive by. Was curious about the work you were doing here so decided to take ...
11 years, 6 months ago (2009-06-09 05:42:05 UTC) #5
eroman
Thanks for the reviews. It turns out I had made some additional changes in my ...
11 years, 6 months ago (2009-06-09 11:15:16 UTC) #6
eroman
> It turns out I had made some additional changes in my client > which ...
11 years, 6 months ago (2009-06-09 11:17:32 UTC) #7
darin (slow to review)
I have only looked address_list.h. Will review more today or tomorrow. Sorry for the delay! ...
11 years, 6 months ago (2009-06-09 18:43:25 UTC) #8
eroman
http://codereview.chromium.org/118100/diff/1509/1542 File net/base/address_list.h (right): http://codereview.chromium.org/118100/diff/1509/1542#newcode24 Line 24: void Copy(const struct addrinfo* head); On 2009/06/09 18:43:25, ...
11 years, 6 months ago (2009-06-09 20:05:02 UTC) #9
darin (slow to review)
Ah, the port number! :(
11 years, 6 months ago (2009-06-09 20:41:08 UTC) #10
willchan no longer on Chromium
I think I still prefer maintaining a separate hash_map in the HostResolver that tracks the ...
11 years, 6 months ago (2009-06-10 02:11:28 UTC) #11
eroman
> I think I still prefer maintaining a separate hash_map in the HostResolver that > ...
11 years, 6 months ago (2009-06-10 17:53:13 UTC) #12
willchan no longer on Chromium
On 2009/06/10 17:53:13, eroman wrote: > > I think I still prefer maintaining a separate ...
11 years, 6 months ago (2009-06-10 21:04:21 UTC) #13
eroman
I believe I have addressed all your comments. (deltas are patchset 15 --> patchset 19). ...
11 years, 6 months ago (2009-06-11 00:07:27 UTC) #14
willchan no longer on Chromium
Sorry for the slowness. I was out most of today in SF. I didn't get ...
11 years, 6 months ago (2009-06-11 08:25:15 UTC) #15
eroman
http://codereview.chromium.org/118100/diff/5074/6065 File net/base/host_cache.cc (right): http://codereview.chromium.org/118100/diff/5074/6065#newcode23 Line 23: bool HostCache::Entry::can_use(const base::TimeTicks now) const { On 2009/06/11 ...
11 years, 6 months ago (2009-06-11 10:37:41 UTC) #16
willchan no longer on Chromium
I'll take a look at the tests and the rest of the code after lunch. ...
11 years, 6 months ago (2009-06-11 20:03:03 UTC) #17
eroman
http://codereview.chromium.org/118100/diff/5074/6065 File net/base/host_cache.cc (right): http://codereview.chromium.org/118100/diff/5074/6065#newcode62 Line 62: entry = new Entry(error, addrlist, expiration); On 2009/06/11 ...
11 years, 6 months ago (2009-06-11 20:19:23 UTC) #18
eroman
http://codereview.chromium.org/118100/diff/5074/6065 File net/base/host_cache.cc (right): http://codereview.chromium.org/118100/diff/5074/6065#newcode62 Line 62: entry = new Entry(error, addrlist, expiration); > I ...
11 years, 6 months ago (2009-06-11 20:30:15 UTC) #19
willchan no longer on Chromium
http://codereview.chromium.org/118100/diff/5074/6065 File net/base/host_cache.cc (right): http://codereview.chromium.org/118100/diff/5074/6065#newcode62 Line 62: entry = new Entry(error, addrlist, expiration); On 2009/06/11 ...
11 years, 6 months ago (2009-06-11 20:50:39 UTC) #20
willchan no longer on Chromium
lgtm http://codereview.chromium.org/118100/diff/5169/5185 File net/ftp/ftp_network_layer.h (right): http://codereview.chromium.org/118100/diff/5169/5185#newcode19 Line 19: FtpNetworkLayer(HostResolver* host_resolver); explicit http://codereview.chromium.org/118100/diff/5169/5181 File net/proxy/proxy_resolver_v8.cc (right): ...
11 years, 6 months ago (2009-06-11 21:07:29 UTC) #21
eroman
Thanks for the review Will! I have synced up to ToT, which allowed me to ...
11 years, 6 months ago (2009-06-11 23:32:05 UTC) #22
wtc
http://codereview.chromium.org/118100/diff/9074/8066 File net/base/address_list.h (right): http://codereview.chromium.org/118100/diff/9074/8066#newcode24 Line 24: void Copy(const struct addrinfo* head); Eric, In the ...
11 years, 6 months ago (2009-06-12 18:40:04 UTC) #23
eroman
11 years, 6 months ago (2009-06-12 20:15:21 UTC) #24
http://codereview.chromium.org/118100/diff/9074/8066
File net/base/address_list.h (right):

http://codereview.chromium.org/118100/diff/9074/8066#newcode24
Line 24: void Copy(const struct addrinfo* head);
On 2009/06/12 18:40:04, wtc wrote:
> Eric,
> 
> In the most common case, we connect to only one or
> two ports (80 or 443) on each host.  So we can get
> rid of the Copy method and the changes to the nested
> struct Data by making a separate getaddrinfo() call
> for a different port number.  This should simplify
> the code.
> 
> What do you think?

That seems really weird to me.

- We would be doing different lookups for the same host.
- The HostCache would need to be keyed by (hostname, port) rather than just
(hostname)
- Less reproducible results for user -- changing port might yield different
address!

Complexity-wise Copy() is only used in one place, so I can't imagine making
duplicate calls for the same host would simplify code any....

Powered by Google App Engine
This is Rietveld 408576698