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

Issue 2881673002: Avoid heap allocations in IPAddress (Closed)

Created:
3 years, 7 months ago by Ryan Hamilton
Modified:
3 years, 7 months ago
CC:
chromium-reviews, cbentzel+watch_chromium.org, qsr+mojo_chromium.org, viettrungluu+watch_chromium.org, yzshen+watch_chromium.org, abarth-chromium, Aaron Boodman, bnc+watch_chromium.org, darin (slow to review), net-reviews_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Avoid heap allocations in IPAddress Use a helper class to represent the sequence of bytes in an IP address. A vector<uint8_t> would be simpler but incurs heap allocation, so IPAddressBytes uses a fixed size array. IPAddress construction and destruction is showing up in cronet profiles consuming roughly 5% of CPU. With this fix, it drops below .1%. Also switch call sites which create IPAddress objects to avoid using std::vector and instead use base::StackVector. Review-Url: https://codereview.chromium.org/2881673002 Cr-Commit-Position: refs/heads/master@{#474780} Committed: https://chromium.googlesource.com/chromium/src/+/c6635f4e242cd2236f85a2b84cc42dfb945ad5d2

Patch Set 1 #

Patch Set 2 : Fix #

Patch Set 3 : remoting #

Patch Set 4 : Fixes #

Patch Set 5 : Comments #

Patch Set 6 : Fix #

Patch Set 7 : More fixes #

Total comments: 53

Patch Set 8 : Address comments #

Total comments: 10

Patch Set 9 : Address comments #

Patch Set 10 : DCHECK #

Total comments: 2

Patch Set 11 : IPC fixed #

Patch Set 12 : Resize #

Total comments: 19

Patch Set 13 : Fix more comments and use StackVector more #

Total comments: 10

Patch Set 14 : Almost there #

Patch Set 15 : Done #

Total comments: 13

Patch Set 16 : more fixes #

Patch Set 17 : Address comments #

Total comments: 2

Patch Set 18 : Rename and Assign #

Total comments: 2

Patch Set 19 : Rebase #

Patch Set 20 : Fix Assign #

Total comments: 2

Patch Set 21 : Fix #

Patch Set 22 : copys #

Total comments: 2

Patch Set 23 : Copyies #

Patch Set 24 : New constructor #

Unified diffs Side-by-side diffs Delta from patch set Stats (+265 lines, -91 lines) Patch
M chrome/browser/media/webrtc/webrtc_text_log_handler.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1 chunk +3 lines, -4 lines 0 comments Download
M content/browser/renderer_host/pepper/pepper_socket_utils.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +1 line, -1 line 0 comments Download
M content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1 chunk +1 line, -1 line 0 comments Download
M content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 2 chunks +2 lines, -2 lines 0 comments Download
M content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 4 chunks +4 lines, -4 lines 0 comments Download
M content/public/common/common_param_traits.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +13 lines, -7 lines 0 comments Download
M net/base/ip_address.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 5 chunks +90 lines, -9 lines 0 comments Download
M net/base/ip_address.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 13 chunks +87 lines, -32 lines 0 comments Download
M net/base/ip_address_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 4 chunks +38 lines, -7 lines 0 comments Download
M net/cert/internal/name_constraints.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +1 line, -1 line 0 comments Download
M net/dns/mdns_client.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +1 line, -1 line 0 comments Download
M net/dns/mojo_host_struct_traits.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +3 lines, -2 lines 0 comments Download
M net/dns/mojo_host_struct_traits.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +2 lines, -1 line 0 comments Download
M net/interfaces/ip_address_struct_traits.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +3 lines, -2 lines 0 comments Download
M net/interfaces/ip_address_struct_traits.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +1 line, -1 line 0 comments Download
M net/quic/platform/impl/quic_ip_address_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +1 line, -3 lines 0 comments Download
M ppapi/shared_impl/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +1 line, -0 lines 0 comments Download
M ppapi/shared_impl/private/net_address_private_impl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 2 chunks +3 lines, -3 lines 0 comments Download
M ppapi/shared_impl/private/net_address_private_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 3 chunks +3 lines, -4 lines 0 comments Download
M remoting/host/daemon_process.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +2 lines, -2 lines 0 comments Download
M remoting/host/ipc_host_event_logger.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +3 lines, -2 lines 0 comments Download
M tools/ipc_fuzzer/fuzzer/fuzzer.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 95 (53 generated)
Ryan Hamilton
3 years, 7 months ago (2017-05-12 18:04:38 UTC) #15
eroman
Some design-level questions before I dive into the details... (1) Did you consider using base/containers/stack_container.h ...
3 years, 7 months ago (2017-05-12 18:56:53 UTC) #18
Ryan Hamilton
On 2017/05/12 18:56:53, eroman wrote: > Some design-level questions before I dive into the details... ...
3 years, 7 months ago (2017-05-12 19:11:52 UTC) #21
Ryan Hamilton
Thanks for the thoughtful comments! Also, happy to chat in person if that'd be more ...
3 years, 7 months ago (2017-05-12 19:13:32 UTC) #22
Ryan Hamilton
On 2017/05/12 19:11:52, Ryan Hamilton wrote: > On 2017/05/12 18:56:53, eroman wrote: > > * ...
3 years, 7 months ago (2017-05-12 21:52:51 UTC) #29
Ryan Hamilton
On 2017/05/12 21:52:51, Ryan Hamilton wrote: > On 2017/05/12 19:11:52, Ryan Hamilton wrote: > > ...
3 years, 7 months ago (2017-05-12 22:22:40 UTC) #34
eroman
Sounds like a good improvement, thanks! https://codereview.chromium.org/2881673002/diff/110001/content/public/common/common_param_traits.cc File content/public/common/common_param_traits.cc (right): https://codereview.chromium.org/2881673002/diff/110001/content/public/common/common_param_traits.cc#newcode127 content/public/common/common_param_traits.cc:127: GetParamSize(s, p.BytesAsVector()); Can ...
3 years, 7 months ago (2017-05-12 23:25:05 UTC) #37
eroman
https://codereview.chromium.org/2881673002/diff/110001/net/base/ip_address.h File net/base/ip_address.h (right): https://codereview.chromium.org/2881673002/diff/110001/net/base/ip_address.h#newcode40 net/base/ip_address.h:40: DCHECK_GT(16u, size); DCHECK_LE(size, 16); Either way, need equality in ...
3 years, 7 months ago (2017-05-12 23:27:02 UTC) #38
Ryan Hamilton
https://codereview.chromium.org/2881673002/diff/110001/content/public/common/common_param_traits.cc File content/public/common/common_param_traits.cc (right): https://codereview.chromium.org/2881673002/diff/110001/content/public/common/common_param_traits.cc#newcode127 content/public/common/common_param_traits.cc:127: GetParamSize(s, p.BytesAsVector()); On 2017/05/12 23:25:04, eroman wrote: > Can ...
3 years, 7 months ago (2017-05-13 13:20:47 UTC) #39
mmenke
On 2017/05/12 19:11:52, Ryan Hamilton wrote: > On 2017/05/12 18:56:53, eroman wrote: > > Some ...
3 years, 7 months ago (2017-05-15 21:14:44 UTC) #40
eroman
https://codereview.chromium.org/2881673002/diff/110001/net/base/ip_address.cc File net/base/ip_address.cc (right): https://codereview.chromium.org/2881673002/diff/110001/net/base/ip_address.cc#newcode141 net/base/ip_address.cc:141: bool operator<(IPAddress::IPAddressBytes lhs, IPAddress::IPAddressBytes rhs) { On 2017/05/13 13:20:46, ...
3 years, 7 months ago (2017-05-15 22:15:24 UTC) #41
eroman
@mmenke: I don't think the unix domain sockets code is reliant on that (it passes ...
3 years, 7 months ago (2017-05-15 22:16:59 UTC) #42
Ryan Hamilton
rdsmith: a question for you about mojo https://codereview.chromium.org/2881673002/diff/110001/net/dns/mojo_host_struct_traits.h File net/dns/mojo_host_struct_traits.h (right): https://codereview.chromium.org/2881673002/diff/110001/net/dns/mojo_host_struct_traits.h#newcode54 net/dns/mojo_host_struct_traits.h:54: return std::vector<uint8_t>(obj.address().bytes().begin(), ...
3 years, 7 months ago (2017-05-17 18:26:42 UTC) #52
Randy Smith (Not in Mondays)
https://codereview.chromium.org/2881673002/diff/110001/net/dns/mojo_host_struct_traits.h File net/dns/mojo_host_struct_traits.h (right): https://codereview.chromium.org/2881673002/diff/110001/net/dns/mojo_host_struct_traits.h#newcode54 net/dns/mojo_host_struct_traits.h:54: return std::vector<uint8_t>(obj.address().bytes().begin(), On 2017/05/17 18:26:41, Ryan Hamilton wrote: > ...
3 years, 7 months ago (2017-05-17 18:53:58 UTC) #54
eroman
https://codereview.chromium.org/2881673002/diff/110001/net/dns/mojo_host_struct_traits.h File net/dns/mojo_host_struct_traits.h (right): https://codereview.chromium.org/2881673002/diff/110001/net/dns/mojo_host_struct_traits.h#newcode54 net/dns/mojo_host_struct_traits.h:54: return std::vector<uint8_t>(obj.address().bytes().begin(), On 2017/05/17 18:53:58, Randy Smith (Not in ...
3 years, 7 months ago (2017-05-17 20:48:17 UTC) #55
Randy Smith (Not in Mondays)
https://codereview.chromium.org/2881673002/diff/110001/net/dns/mojo_host_struct_traits.h File net/dns/mojo_host_struct_traits.h (right): https://codereview.chromium.org/2881673002/diff/110001/net/dns/mojo_host_struct_traits.h#newcode54 net/dns/mojo_host_struct_traits.h:54: return std::vector<uint8_t>(obj.address().bytes().begin(), On 2017/05/17 20:48:16, eroman wrote: > On ...
3 years, 7 months ago (2017-05-17 20:52:55 UTC) #56
Ryan Hamilton
https://codereview.chromium.org/2881673002/diff/110001/net/dns/mojo_host_struct_traits.h File net/dns/mojo_host_struct_traits.h (right): https://codereview.chromium.org/2881673002/diff/110001/net/dns/mojo_host_struct_traits.h#newcode54 net/dns/mojo_host_struct_traits.h:54: return std::vector<uint8_t>(obj.address().bytes().begin(), On 2017/05/17 20:52:54, Randy Smith (Not in ...
3 years, 7 months ago (2017-05-17 23:14:05 UTC) #57
Ryan Hamilton
https://codereview.chromium.org/2881673002/diff/170001/net/base/ip_address.h File net/base/ip_address.h (right): https://codereview.chromium.org/2881673002/diff/170001/net/base/ip_address.h#newcode39 net/base/ip_address.h:39: // of the underlying array. Zeros out all elements ...
3 years, 7 months ago (2017-05-17 23:32:37 UTC) #58
eroman
lgtm! https://codereview.chromium.org/2881673002/diff/210001/content/public/common/common_param_traits.cc File content/public/common/common_param_traits.cc (right): https://codereview.chromium.org/2881673002/diff/210001/content/public/common/common_param_traits.cc#newcode128 content/public/common/common_param_traits.cc:128: base::StackVector<uint8_t, 16> bytes; Better thanks! https://codereview.chromium.org/2881673002/diff/210001/content/public/common/common_param_traits.cc#newcode145 content/public/common/common_param_traits.cc:145: std::vector<uint8_t> ...
3 years, 7 months ago (2017-05-18 18:43:18 UTC) #59
yzshen1
https://codereview.chromium.org/2881673002/diff/110001/net/dns/mojo_host_struct_traits.h File net/dns/mojo_host_struct_traits.h (right): https://codereview.chromium.org/2881673002/diff/110001/net/dns/mojo_host_struct_traits.h#newcode54 net/dns/mojo_host_struct_traits.h:54: return std::vector<uint8_t>(obj.address().bytes().begin(), On 2017/05/17 18:53:58, Randy Smith (Not in ...
3 years, 7 months ago (2017-05-18 22:32:47 UTC) #60
Ryan Hamilton
https://codereview.chromium.org/2881673002/diff/110001/net/dns/mojo_host_struct_traits.h File net/dns/mojo_host_struct_traits.h (right): https://codereview.chromium.org/2881673002/diff/110001/net/dns/mojo_host_struct_traits.h#newcode54 net/dns/mojo_host_struct_traits.h:54: return std::vector<uint8_t>(obj.address().bytes().begin(), On 2017/05/18 22:32:47, yzshen1 wrote: > On ...
3 years, 7 months ago (2017-05-19 03:38:50 UTC) #61
yzshen1
https://codereview.chromium.org/2881673002/diff/110001/net/dns/mojo_host_struct_traits.h File net/dns/mojo_host_struct_traits.h (right): https://codereview.chromium.org/2881673002/diff/110001/net/dns/mojo_host_struct_traits.h#newcode54 net/dns/mojo_host_struct_traits.h:54: return std::vector<uint8_t>(obj.address().bytes().begin(), On 2017/05/19 03:38:49, Ryan Hamilton wrote: > ...
3 years, 7 months ago (2017-05-19 16:04:04 UTC) #62
eroman
still lgtm https://codereview.chromium.org/2881673002/diff/210001/content/public/common/common_param_traits.cc File content/public/common/common_param_traits.cc (right): https://codereview.chromium.org/2881673002/diff/210001/content/public/common/common_param_traits.cc#newcode145 content/public/common/common_param_traits.cc:145: std::vector<uint8_t> bytes; On 2017/05/19 03:38:50, Ryan Hamilton ...
3 years, 7 months ago (2017-05-19 17:37:54 UTC) #63
Ryan Hamilton
On 2017/05/19 16:04:04, yzshen1 wrote: > https://codereview.chromium.org/2881673002/diff/110001/net/dns/mojo_host_struct_traits.h > File net/dns/mojo_host_struct_traits.h (right): > > https://codereview.chromium.org/2881673002/diff/110001/net/dns/mojo_host_struct_traits.h#newcode54 > ...
3 years, 7 months ago (2017-05-19 19:13:04 UTC) #64
Ryan Hamilton
Ok, I think I've got this wrapped up. (Time to find non-net OWNERS :>) https://codereview.chromium.org/2881673002/diff/210001/content/public/common/common_param_traits.cc ...
3 years, 7 months ago (2017-05-19 21:30:46 UTC) #66
Ryan Hamilton
sergeyu: chrome/browser/media/webrtc/ remoting/host/ raymes: content/browser/renderer_host/pepper/ ppapi/shared_impl/private/ mbarbella: content/public/common/ tools/ipc_fuzzer/
3 years, 7 months ago (2017-05-19 21:37:24 UTC) #69
eroman
https://codereview.chromium.org/2881673002/diff/290001/chrome/browser/media/webrtc/webrtc_text_log_handler.cc File chrome/browser/media/webrtc/webrtc_text_log_handler.cc (right): https://codereview.chromium.org/2881673002/diff/290001/chrome/browser/media/webrtc/webrtc_text_log_handler.cc#newcode81 chrome/browser/media/webrtc/webrtc_text_log_handler.cc:81: base::StackVector<uint8_t, 16> bytes; How about without StackVector: net::IPAddressBytes stripped ...
3 years, 7 months ago (2017-05-19 22:00:07 UTC) #70
Ryan Hamilton
https://codereview.chromium.org/2881673002/diff/290001/chrome/browser/media/webrtc/webrtc_text_log_handler.cc File chrome/browser/media/webrtc/webrtc_text_log_handler.cc (right): https://codereview.chromium.org/2881673002/diff/290001/chrome/browser/media/webrtc/webrtc_text_log_handler.cc#newcode81 chrome/browser/media/webrtc/webrtc_text_log_handler.cc:81: base::StackVector<uint8_t, 16> bytes; On 2017/05/19 22:00:07, eroman wrote: > ...
3 years, 7 months ago (2017-05-20 03:21:44 UTC) #71
Sergey Ulanov
remoting lgtm
3 years, 7 months ago (2017-05-20 20:27:17 UTC) #72
eroman
https://codereview.chromium.org/2881673002/diff/290001/chrome/browser/media/webrtc/webrtc_text_log_handler.cc File chrome/browser/media/webrtc/webrtc_text_log_handler.cc (right): https://codereview.chromium.org/2881673002/diff/290001/chrome/browser/media/webrtc/webrtc_text_log_handler.cc#newcode81 chrome/browser/media/webrtc/webrtc_text_log_handler.cc:81: base::StackVector<uint8_t, 16> bytes; On 2017/05/20 03:21:44, Ryan Hamilton wrote: ...
3 years, 7 months ago (2017-05-22 18:06:45 UTC) #73
Martin Barbella
traits and ipc_fuzzer lgtm
3 years, 7 months ago (2017-05-22 20:47:07 UTC) #74
Ryan Hamilton
raymes, ping. Hopefully you can approve content/browser/renderer_host/pepper/ ppapi/shared_impl/private/
3 years, 7 months ago (2017-05-22 21:09:02 UTC) #75
Ryan Hamilton
https://codereview.chromium.org/2881673002/diff/290001/ppapi/shared_impl/private/net_address_private_impl.cc File ppapi/shared_impl/private/net_address_private_impl.cc (right): https://codereview.chromium.org/2881673002/diff/290001/ppapi/shared_impl/private/net_address_private_impl.cc#newcode500 ppapi/shared_impl/private/net_address_private_impl.cc:500: &net_addr->address[address_size]); On 2017/05/22 18:06:44, eroman wrote: > On 2017/05/20 ...
3 years, 7 months ago (2017-05-22 22:12:33 UTC) #76
raymes
Sorry for the delay - didn't realize I was a reviewer. pepper lgtm
3 years, 7 months ago (2017-05-22 22:35:48 UTC) #77
eroman
https://codereview.chromium.org/2881673002/diff/340001/net/base/ip_address.cc File net/base/ip_address.cc (right): https://codereview.chromium.org/2881673002/diff/340001/net/base/ip_address.cc#newcode148 net/base/ip_address.cc:148: std::copy_n(data, data_len, bytes_.data()); This is missing: size_ = data_len;
3 years, 7 months ago (2017-05-22 22:46:53 UTC) #78
Ryan Hamilton
https://codereview.chromium.org/2881673002/diff/340001/net/base/ip_address.cc File net/base/ip_address.cc (right): https://codereview.chromium.org/2881673002/diff/340001/net/base/ip_address.cc#newcode148 net/base/ip_address.cc:148: std::copy_n(data, data_len, bytes_.data()); On 2017/05/22 22:46:53, eroman wrote: > ...
3 years, 7 months ago (2017-05-23 04:39:28 UTC) #79
eroman
https://codereview.chromium.org/2881673002/diff/380001/net/base/ip_address.h File net/base/ip_address.h (right): https://codereview.chromium.org/2881673002/diff/380001/net/base/ip_address.h#newcode31 net/base/ip_address.h:31: // Copys |data_len| elements from |data| into this object. ...
3 years, 7 months ago (2017-05-23 22:06:11 UTC) #84
Ryan Hamilton
https://codereview.chromium.org/2881673002/diff/380001/net/base/ip_address.h File net/base/ip_address.h (right): https://codereview.chromium.org/2881673002/diff/380001/net/base/ip_address.h#newcode31 net/base/ip_address.h:31: // Copys |data_len| elements from |data| into this object. ...
3 years, 7 months ago (2017-05-24 19:30:44 UTC) #87
eroman
https://codereview.chromium.org/2881673002/diff/420001/net/base/ip_address.h File net/base/ip_address.h (right): https://codereview.chromium.org/2881673002/diff/420001/net/base/ip_address.h#newcode31 net/base/ip_address.h:31: // Copyies |data_len| elements from |data| into this object. ...
3 years, 7 months ago (2017-05-24 20:07:28 UTC) #88
Ryan Hamilton
https://codereview.chromium.org/2881673002/diff/420001/net/base/ip_address.h File net/base/ip_address.h (right): https://codereview.chromium.org/2881673002/diff/420001/net/base/ip_address.h#newcode31 net/base/ip_address.h:31: // Copyies |data_len| elements from |data| into this object. ...
3 years, 7 months ago (2017-05-24 20:31:20 UTC) #89
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2881673002/460001
3 years, 7 months ago (2017-05-25 18:42:14 UTC) #92
commit-bot: I haz the power
3 years, 7 months ago (2017-05-25 20:32:07 UTC) #95
Message was sent while issue was closed.
Committed patchset #24 (id:460001) as
https://chromium.googlesource.com/chromium/src/+/c6635f4e242cd2236f85a2b84cc4...

Powered by Google App Engine
This is Rietveld 408576698