Chromium Code Reviews

Issue 4118004: Update NetLog to be thread safe. (Closed)

Created:
10 years, 1 month ago by mmenke
Modified:
9 years, 7 months ago
Reviewers:
eroman, willchan no longer on Chromium
CC:
chromium-reviews, cbentzel+watch_chromium.org, darin-cc_chromium.org, ben+cc_chromium.org
Visibility:
Public.

Description

Update NetLog to be threadsafe. The ChromeNetLog is now owned by the browser process, and passed to the IOThread on creation. NetLog entries can be added from any thread. Observers must be able to handle having log entries added from any thread. Observers can add/remove themselves on any thread. BUG=63334 TEST=None, yet Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=67851

Patch Set 1 : '' #

Patch Set 2 : Requires threadsafe observers #

Total comments: 16

Patch Set 3 : Response to comments #

Total comments: 34

Patch Set 4 : Response to comments (And net-internals refresh fix) #

Total comments: 23

Patch Set 5 : Response to comments #

Patch Set 6 : Sync with trunk before updating unittests. #

Patch Set 7 : Updating unittests, as CapturingNetLog changed. #

Patch Set 8 : Linux/Mac fix #

Patch Set 9 : Unit test, load timing observer unittest #

Patch Set 10 : Add short test description #

Total comments: 15

Patch Set 11 : '' #

Patch Set 12 : Sync with trunk #

Total comments: 1

Patch Set 13 : nit fix #

Patch Set 14 : slight cleanup #

Patch Set 15 : Final sync with trunk #

Unified diffs Side-by-side diffs Stats (+976 lines, -784 lines)
M chrome/browser/browser_process_impl.h View 2 chunks +4 lines, -0 lines 0 comments
M chrome/browser/browser_process_impl.cc View 3 chunks +4 lines, -1 line 0 comments
MM chrome/browser/debugger/devtools_netlog_observer.h View 1 chunk +6 lines, -2 lines 0 comments
M chrome/browser/debugger/devtools_netlog_observer.cc View 3 chunks +6 lines, -2 lines 0 comments
M chrome/browser/dom_ui/net_internals_ui.cc View 15 chunks +62 lines, -48 lines 0 comments
M chrome/browser/io_thread.h View 3 chunks +9 lines, -9 lines 0 comments
M chrome/browser/io_thread.cc View 6 chunks +9 lines, -16 lines 0 comments
M chrome/browser/net/chrome_net_log.h View 3 chunks +91 lines, -18 lines 0 comments
M chrome/browser/net/chrome_net_log.cc View 3 chunks +86 lines, -28 lines 0 comments
A chrome/browser/net/chrome_net_log_unittest.cc View 1 chunk +73 lines, -0 lines 0 comments
M chrome/browser/net/chrome_url_request_context.cc View 6 chunks +7 lines, -7 lines 0 comments
M chrome/browser/net/connection_tester_unittest.cc View 1 chunk +1 line, -1 line 0 comments
MM chrome/browser/net/load_timing_observer.h View 2 chunks +5 lines, -2 lines 0 comments
M chrome/browser/net/load_timing_observer.cc View 8 chunks +14 lines, -2 lines 0 comments
MM chrome/browser/net/load_timing_observer_unittest.cc View 12 chunks +22 lines, -11 lines 0 comments
M chrome/browser/net/net_log_logger.h View 1 chunk +2 lines, -2 lines 0 comments
M chrome/browser/net/net_log_logger.cc View 1 chunk +3 lines, -1 line 0 comments
M chrome/browser/net/passive_log_collector.h View 14 chunks +35 lines, -44 lines 0 comments
M chrome/browser/net/passive_log_collector.cc View 19 chunks +39 lines, -47 lines 0 comments
M chrome/browser/net/passive_log_collector_unittest.cc View 4 chunks +8 lines, -8 lines 0 comments
M chrome/browser/policy/device_management_backend_impl.cc View 0 chunks +-1 lines, --1 lines 0 comments
M chrome/browser/resources/net_internals/main.js View 3 chunks +16 lines, -10 lines 0 comments
M chrome/chrome_tests.gypi View 1 chunk +1 line, -0 lines 0 comments
M net/base/capturing_net_log.h View 3 chunks +11 lines, -10 lines 0 comments
M net/base/capturing_net_log.cc View 3 chunks +14 lines, -10 lines 0 comments
D net/base/forwarding_net_log.h View 1 chunk +0 lines, -54 lines 0 comments
D net/base/forwarding_net_log.cc View 1 chunk +0 lines, -96 lines 0 comments
D net/base/forwarding_net_log_unittest.cc View 1 chunk +0 lines, -84 lines 0 comments
M net/base/host_resolver_impl_unittest.cc View 4 chunks +36 lines, -19 lines 0 comments
M net/base/net_log.h View 1 chunk +0 lines, -3 lines 0 comments
M net/http/http_auth_handler_unittest.cc View 1 chunk +6 lines, -5 lines 0 comments
net/http/http_cache_unittest.cc View 4 chunks +45 lines, -34 lines 0 comments
M net/http/http_network_transaction_unittest.cc View 6 chunks +26 lines, -13 lines 0 comments
M net/net.gyp View 2 chunks +0 lines, -3 lines 0 comments
M net/proxy/init_proxy_resolver_unittest.cc View 5 chunks +51 lines, -36 lines 0 comments
M net/proxy/multi_threaded_proxy_resolver.cc View 4 chunks +4 lines, -16 lines 0 comments
M net/proxy/multi_threaded_proxy_resolver_unittest.cc View 2 chunks +25 lines, -11 lines 0 comments
M net/proxy/proxy_resolver_js_bindings_unittest.cc View 1 chunk +40 lines, -23 lines 0 comments
M net/proxy/proxy_resolver_v8_unittest.cc View 1 chunk +3 lines, -1 line 0 comments
M net/proxy/proxy_service.cc View 4 chunks +4 lines, -11 lines 0 comments
M net/proxy/proxy_service_unittest.cc View 4 chunks +30 lines, -18 lines 0 comments
M net/socket/client_socket_pool_base_unittest.cc View 6 chunks +44 lines, -26 lines 0 comments
M net/socket/socks5_client_socket_unittest.cc View 5 chunks +31 lines, -10 lines 0 comments
M net/socket/socks_client_socket_unittest.cc View 7 chunks +44 lines, -15 lines 0 comments
M net/socket/ssl_client_socket_snapstart_unittest.cc View 2 chunks +6 lines, -4 lines 0 comments
M net/socket/ssl_client_socket_unittest.cc View 9 chunks +35 lines, -12 lines 0 comments
M net/socket/tcp_client_socket_unittest.cc View 2 chunks +7 lines, -3 lines 0 comments
M net/spdy/spdy_network_transaction_unittest.cc View 1 chunk +12 lines, -9 lines 0 comments

Messages

Total messages: 24 (0 generated)
mmenke
Just wanted to see what you thought of this before I continue to work on ...
10 years, 1 month ago (2010-10-28 17:58:39 UTC) #1
mmenke
Think I'll break this up into two CLs...one for the thread safety, another for putting ...
10 years, 1 month ago (2010-10-29 19:56:06 UTC) #2
eroman
[+willchan] for his take on the use of refcounting. Some initial high-level comments: - I ...
10 years, 1 month ago (2010-10-29 21:49:00 UTC) #3
willchan no longer on Chromium
<caveat> I haven't read any of the code yet </caveat> I think that making NetLog ...
10 years, 1 month ago (2010-10-30 00:53:30 UTC) #4
mmenke
- I'm not overly fond of the idea of ref counting the NetLog, but I'm ...
10 years, 1 month ago (2010-11-01 19:27:20 UTC) #5
mmenke
One other potential issue with the ObserverListThreadSafe - we'd lose events on quit. The IO ...
10 years, 1 month ago (2010-11-01 19:32:54 UTC) #6
willchan no longer on Chromium
On Mon, Nov 1, 2010 at 7:27 PM, <mmenke@chromium.org> wrote: > - I'm not overly ...
10 years, 1 month ago (2010-11-01 19:40:01 UTC) #7
eroman
Hi Matt, thanks for your comment responses. You are right, if we added IDs in ...
10 years, 1 month ago (2010-11-01 20:03:47 UTC) #8
mmenke
willchan: I'll look into why the cache thread is destroyed before the IO thread. I ...
10 years, 1 month ago (2010-11-01 21:55:11 UTC) #9
willchan no longer on Chromium
On Mon, Nov 1, 2010 at 9:55 PM, <mmenke@chromium.org> wrote: > willchan: > > I'll ...
10 years, 1 month ago (2010-11-01 22:19:25 UTC) #10
willchan no longer on Chromium
On Mon, Nov 1, 2010 at 8:03 PM, <eroman@chromium.org> wrote: > Hi Matt, thanks for ...
10 years, 1 month ago (2010-11-01 22:23:55 UTC) #11
mmenke
On 2010/11/01 22:19:25, willchan wrote: > Ok. This doesn't mean it needs to be refcounted. ...
10 years, 1 month ago (2010-11-01 22:31:43 UTC) #12
mmenke
I'm still not sure this is the best approach, but here's a pass at requiring ...
10 years, 1 month ago (2010-11-12 19:26:48 UTC) #13
eroman
Ooops, forgot to hit publish for my comments! Sry. Better late then never :-) http://codereview.chromium.org/4118004/diff/114002/chrome/browser/debugger/devtools_netlog_observer.cc ...
10 years, 1 month ago (2010-11-16 17:51:14 UTC) #14
mmenke
http://codereview.chromium.org/4118004/diff/114002/chrome/browser/debugger/devtools_netlog_observer.cc File chrome/browser/debugger/devtools_netlog_observer.cc (right): http://codereview.chromium.org/4118004/diff/114002/chrome/browser/debugger/devtools_netlog_observer.cc#newcode61 chrome/browser/debugger/devtools_netlog_observer.cc:61: BrowserThread::PostTask(BrowserThread::IO, On 2010/11/16 17:51:14, eroman wrote: > Can we ...
10 years, 1 month ago (2010-11-16 21:34:48 UTC) #15
eroman
The overall approach looks good, but I do have a number of comments on the ...
10 years, 1 month ago (2010-11-17 05:58:58 UTC) #16
mmenke
Noticed a bug in refreshing the net-internals page and fixed it. Would do it in ...
10 years, 1 month ago (2010-11-17 21:42:14 UTC) #17
eroman
I would like to do one more review pass after these comments are addressed before ...
10 years, 1 month ago (2010-11-18 18:04:03 UTC) #18
mmenke
In terms of performance, we're able to log about 30 entries per millisecond in a ...
10 years, 1 month ago (2010-11-23 16:48:45 UTC) #19
eroman
LGTM http://codereview.chromium.org/4118004/diff/390004/chrome/browser/net/chrome_net_log.cc File chrome/browser/net/chrome_net_log.cc (right): http://codereview.chromium.org/4118004/diff/390004/chrome/browser/net/chrome_net_log.cc#newcode124 chrome/browser/net/chrome_net_log.cc:124: DCHECK(!observer->net_log_); nit: perhaps you could extract the shared ...
10 years ago (2010-11-30 01:43:37 UTC) #20
mmenke
Performance Note: I experimentally loaded 5 websites (news.google.com, youtube, cnn, bbc.co.uk, and hulu), and that ...
10 years ago (2010-11-30 18:59:04 UTC) #21
eroman
lgtm
10 years ago (2010-11-30 19:15:38 UTC) #22
eroman
http://codereview.chromium.org/4118004/diff/429002/chrome/browser/net/chrome_net_log.cc File chrome/browser/net/chrome_net_log.cc (right): http://codereview.chromium.org/4118004/diff/429002/chrome/browser/net/chrome_net_log.cc#newcode10 chrome/browser/net/chrome_net_log.cc:10: #include "base/lock.h" nit: include lock.h from the header file ...
10 years ago (2010-11-30 19:20:20 UTC) #23
mmenke
10 years ago (2010-11-30 20:39:12 UTC) #24
A couple more speed results, for posterity (Passive log collector logging when
entries are cleared now turned off).  Already talked a bit with eroman about
them, but thought I'd post them anyways.

While I've tried to get numbers more accurate than before, time taken can vary
quite a bit between runs of identical binaries (Sometimes can take as much as
twice as long), so these are just rough averages:

1) With everything:  340/ms
2) With no passive log collector:  910/ms
3) With no load timing observer:  400/ms
4) With no observers:  1500/ms
5) With both observers, but only one source id per thread:  2000/ms

The last is likely only faster than the second to last because of random runtime
variations.

So it looks like the passive log collector adding/clearing sources may currently
the limiting factor, in terms of speed (Or possibly searching through old
sources for duplicates).  In real world situations, I'm not sure if things look
more like 1) or 5).

I'm planning to go ahead and commit tomorrow morning/early afternoon, as it's a
big change, and things tend to be a little less active earlier in the day.

On 2010/11/30 19:20:20, eroman wrote:
>
http://codereview.chromium.org/4118004/diff/429002/chrome/browser/net/chrome_...
> File chrome/browser/net/chrome_net_log.cc (right):
> 
>
http://codereview.chromium.org/4118004/diff/429002/chrome/browser/net/chrome_...
> chrome/browser/net/chrome_net_log.cc:10: #include "base/lock.h"
> nit: include lock.h from the header file instead (since it has a lock member).

Fixed.

Powered by Google App Engine