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

Issue 684732 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Jan 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug

Blocking:
issue 620852



Sign in to add a comment

DiskCacheBasedQuicServerInfo holds on read and write buffers

Project Member Reported by xunji...@chromium.org, Jan 24 2017

Issue description

DiskCacheBasedQuicServerInfo currently holds onto ~8KiB read and write buffers when these buffers are not needed. This amounts to a non-trivial amount of memory usage when the number of Quic sessions is big. (In a 2min browsing session, I have 8 Quic session and 64kiB buffers owned by DiskCacheBasedQuicServerInfo.)

We need to release these read/write buffers when done reading/writing from disk cache.

 
Blocking: 620852
Components: Internals>Network>Cache
net::DiskCacheBasedQuicServerInfo::DoRead() and net::DiskCacheBasedQuicServerInfo::DoWrite() has 16 IOBuffers totaling 34*2KiB. Attached is the trace file.
trace_disk_cache_based_quic_server_info_read_write_buffers.json.gz
5.2 MB Download
Screenshot from 2017-01-24 16:39:37.png
150 KB View Download

Comment 3 by ssid@chromium.org, Jan 24 2017

Cc: dskiba@chromium.org
Labels: Performance-Memory
If it's 64KiB that we are not using on a 2 minute session in Android, then it sounds like a higher priority bug.
I do not understand why we have write buffers in the first place. It looks like DiskCacheBasedQuicServerInfo::DoWrite is the only function that uses the buffer and it clears it at every call. there is no state stored here.
Cc: rvargas@chromium.org
https://cs.chromium.org/chromium/src/net/disk_cache/disk_cache.h?rcl=0&l=228

scoped_refptr<IOBuffer> write_buffer_;

Disk Cache writes happen asynchronously. We pass the pointer to the data to disk cache backend (it could write data at some point in future). When did you take the logs? Is it after the data is flushed to the  disk?

We use scoped_refptr to define the IOBuffer (at other places where disk_cache entry is used).

https://cs.chromium.org/chromium/src/gpu/ipc/host/shader_disk_cache.cc?rcl=0&l=204



Comment 5 by dskiba@chromium.org, Jan 24 2017

But can we free the write buffer in DoWriteComplete()?
Good point. I don't know the answer (please pardon me for my ignorance). 

Experts of disk cache would know. The following is another example of scoped_refptr being used with disk cache entry.

https://cs.chromium.org/chromium/src/net/tools/stress_cache/stress_cache.cc?q=entry_-%3EWriteData&sq=package:chromium&l=217&dr=C
Project Member

Comment 7 by bugdroid1@chromium.org, Jan 25 2017

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

commit e60eae52ad27b1d5814eeecf6575916be0e5b14c
Author: xunjieli <xunjieli@chromium.org>
Date: Wed Jan 25 00:23:58 2017

Make DiskCacheBasedQuicServerInfo release buffers when no longer needed

When read/write is completed in DiskCacheBasedQuicServerInfo,
release read/write IOBuffer.

BUG= 684732 

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

[modify] https://crrev.com/e60eae52ad27b1d5814eeecf6575916be0e5b14c/net/http/disk_cache_based_quic_server_info.cc

correct. No need to keep the buffer after the op completes.
Thanks rvargas@.
Status: Fixed (was: Started)
I forgot to say that I have a CL in review when I filed the bug.
Would be good to fix the other places where IOBuffer is not being free'ed immediately in the write complete callback (if it makes sense).
I have fixed the write buffer case as well (in https://codereview.chromium.org/2649043005). Am I missing something?
Thanks xunjieli@.

I was suggesting for the memory performance team to see if there are other similar uses outside net.

The following shows all the calls where we call WriteData. Sometimes, wrong patterns of the code are copied. 

https://cs.chromium.org/search/?q=%22+entry_-%3EWriteData%22&sq=package:chromium&type=cs
Got it. Thanks Raman. I will look through other call places of the disk cache API.

Sign in to add a comment