New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 621197 link

Starred by 7 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Sep 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocking:
issue 620852



Sign in to add a comment

Investigate keeping fewer idle sockets around on Android

Project Member Reported by mmenke@chromium.org, Jun 17 2016

Issue description

Idle SSL sockets use over 28k each, and it's not hard to end up with over 50 of them.  This is a significant amount of memory on mobile, and it would be great it we could do something smarter without significantly harming performance.

It's worth noting that closing idle sockets can wake up the radio, consuming power, so we want to make sure we close them in as few batches as we can, or share that cost with sending data / creating new connections.
 
Do we have metrics for idle socket use? I'm wondering if turning off the predictor in an experiment can show how much of these sockets are the predictors fault.

Comment 2 by mmenke@chromium.org, Jun 17 2016

We close idle sockets that were never used in 10 seconds (Well...when a socket is requested, and they've been unused for 10 seconds), so I don't think the predictor is the main culprit here.  With multiple navigations, we basically only have the predictor's never used sockets from the last navigation hanging around, at worst, assuming the navigations are >= 10 seconds apart, and all make at least one network request (i.e., aren't entirely served from the cache).

Not that it's not worth thinking about predictor sockets, but I don't think that's the first place to focus.
Ah right, if the sockets are used then it isn't really the predictor's fault :)

Could we get "idle time before reconnect" metric? I wonder if we can kill the socket on a 95 percentile of use or something (could even make this dynamic... might be overkill)

Comment 4 by mmenke@chromium.org, Jun 17 2016

That sounds like a good place to start.

We could also consider adding some sort of metrics based on number of idle sockets in the pool.  If I decide to never have more than 20 (30?) idle sockets in the socket pool, and just close the oldest socket when that happens (Or least frequently used?  Or most recent?), how much does that cost us?  HTTP2 does confuse that metric a bit, though at least we only keep around one connection per HTTP2 server.

Comment 5 by mmenke@chromium.org, Jun 20 2016

Labels: Performance-Memory

Comment 6 by mmenke@chromium.org, Jun 21 2016

Owner: mmenke@chromium.org
Status: Assigned (was: Untriaged)
Project Member

Comment 7 by bugdroid1@chromium.org, Jun 22 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a9d6c7d3dc9a4a700ab9bf0aa71581540e014cd3

commit a9d6c7d3dc9a4a700ab9bf0aa71581540e014cd3
Author: mmenke <mmenke@chromium.org>
Date: Wed Jun 22 18:48:31 2016

net: Add some metrics on reuse of idle sockets.

We're investigating keeping fewer of them around, and/or timing them out
more aggressively to decrease memory usage.

BUG= 621197 

Review-Url: https://codereview.chromium.org/2086903003
Cr-Commit-Position: refs/heads/master@{#401370}

[modify] https://crrev.com/a9d6c7d3dc9a4a700ab9bf0aa71581540e014cd3/net/socket/client_socket_pool_base.cc
[modify] https://crrev.com/a9d6c7d3dc9a4a700ab9bf0aa71581540e014cd3/tools/metrics/histograms/histograms.xml

Comment 8 by mmenke@chromium.org, Sep 29 2016

Components: Internals>Network
https://uma.googleplex.com/p/chrome/histograms?endDate=20161128&dayCount=1&histograms=Net.Socket.IdleSocketFate%2CNet.Socket.IdleSocketReuseTime&fixupData=true&showMax=true&filters=channel%2Ceq%2C1%2Cplatform%2Ceq%2CA%2Cisofficial%2Ceq%2CTrue&implicitFilters=isofficial

We recently also added a Net.Socket.IdleSocketFate histogram. From the data in Canary, idle socket reuse rate is pretty high. Majority of socket reuse happen within 1 second. There is a small difference between Android and Windows. On Android, more sockets are cleaned up because connection is closed or timed out. I will wait for more data to come in since the Canary population is small. Let me know if you have any interpretation from the current data.
Cc: mmenke@chromium.org
Owner: ----
Status: Available (was: Assigned)
Cc: mariakho...@chromium.org
Maria - is this something you would track?
Cc: xunji...@chromium.org
Status: WontFix (was: Available)
mmenke@ and I added some histograms to investigate. Data showed that idle socket reuse rate is pretty high (~50% on Desktop and ~30 on Android). Idle sockets do not really retain much memory, after a few improvements in this area (use CRYPTO_BUFFER  Issue 671420  and lazy buffer initialization  Issue 524258 ).

mmenke@ removed his histogram in r8152dd7e39b668b61890503cfba8af0591464029 and I removed mine in ra46c80057c897f53772701bbde45b551401b691e.

Since idle sockets no longer use 28K of memory, I will mark this as WontFix. 


Worth noting that's just chrome-allocated memory.  Unclear how much memory sockets really take up behind the scenes.
Yes, it's unclear how much memory each idle socket consumes in the OS. We can only improve what we can see from the data we have.

Sign in to add a comment