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

Issue 87983002: Add WTF::DiscardableMemory. (Closed)

Created:
7 years ago by Philippe
Modified:
7 years ago
CC:
blink-reviews, yurys+blink_chromium.org, loislo+blink_chromium.org, adamk+blink_chromium.org, Chris Evans, Tom Sepez
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Visibility:
Public.

Description

Add WTF::DiscardableMemory. This will allow WTF::Vector to be purgeable (only when the client requested so at construction). In order to achieve this, the WTFPlatform interface is added to WTF. This interface is currently nothing more than an abstract factory used to create instances of WTF::DiscardableMemory. When the platform layer is initialized, it injects its implementation of this interface (which is basically a wrapper around a very small subset of blink::Platform). As it has always been the case, DiscardableMemory can be a limited resource on certain platforms (although it's changing on Android: https://chromiumcodereview.appspot.com/25293002). It is also expensive to instantiante (due to the syscall incurred and possibly the amount of layers that have to be crossed) therefore clients (now possibly in WTF) should use it carefully. BUG=323454

Patch Set 1 #

Patch Set 2 : Rebase #

Patch Set 3 : Update comment #

Unified diffs Side-by-side diffs Delta from patch set Stats (+93 lines, -34 lines) Patch
M Source/platform/exported/Platform.cpp View 1 1 chunk +54 lines, -1 line 0 comments Download
A + Source/wtf/DiscardableMemory.h View 1 2 3 chunks +9 lines, -9 lines 0 comments Download
A + Source/wtf/WTFPlatform.h View 1 1 chunk +19 lines, -20 lines 0 comments Download
A + Source/wtf/WTFPlatform.cpp View 1 chunk +8 lines, -4 lines 0 comments Download
M Source/wtf/wtf.gypi View 1 2 chunks +3 lines, -0 lines 0 comments Download

Messages

Total messages: 9 (0 generated)
Philippe
Hi guys, what do you think?
7 years ago (2013-11-26 12:31:02 UTC) #1
eseidel
I don't recall WTF having other interfaces poking out the bottom of it like this. ...
7 years ago (2013-11-26 15:47:11 UTC) #2
Philippe
On 2013/11/26 15:47:11, eseidel wrote: > I don't recall WTF having other interfaces poking out ...
7 years ago (2013-11-26 15:54:53 UTC) #3
abarth-chromium
What's the use case for Vector to be backed by discardable memory? Thus far, we've ...
7 years ago (2013-11-26 17:35:00 UTC) #4
Philippe
On 2013/11/26 17:35:00, abarth wrote: > What's the use case for Vector to be backed ...
7 years ago (2013-11-26 17:58:37 UTC) #5
abarth-chromium
On 2013/11/26 17:58:37, Philippe wrote: > What do you think? IMHO, you shouldn't change anything ...
7 years ago (2013-11-26 18:15:50 UTC) #6
Philippe
On 2013/11/26 18:15:50, abarth wrote: > On 2013/11/26 17:58:37, Philippe wrote: > > What do ...
7 years ago (2013-11-26 19:09:40 UTC) #7
eseidel
If we need to make specific things like script source purgable, we should just do ...
7 years ago (2013-11-29 20:23:59 UTC) #8
Philippe
7 years ago (2013-12-02 17:14:30 UTC) #9
Message was sent while issue was closed.
On 2013/11/29 20:23:59, eseidel wrote:
> If we need to make specific things like script source purgable, we should just
> do so at a higher level. :)  StringImpl and Vector are too low level.
> 
> SharedBuffer is a vector-like wrapper which used to wrap NSData on Mac and
wraps
> other possibly-shared, possibly-purgable memory regions on other platforms.
> 
> We also have a ScriptSourceCode wrapper around StringImpl which we could
instead
> use to wrap something purgable if necessary.
> 
> For better or worse, we have to keep the source code around in the DOM for web
> compatiblity.  We talked about adding an attribute to <script> to allow it to
be
> purgeable from the DOM.  Big apps like Gmail would probably want something
like
> that.

Yes, thanks Eric. I will implement this in SharedBuffer instead. I was too
ambitious by doing it in Vector :) I will probably do some independent changes
in SharedBuffer too to be more DiscardableMemory friendly. Currently
SharedBuffer has a fixed-size allocation granularity of a single page (it
maintains a vector of pointers to single pages). I would like to make
SharedBuffer allocate segments whose size would grow exponentially in order to
decrease the amount of allocations (DiscardableMemory can be expensive to
allocate) and more importantly have less chunks but bigger ones. This would mean
less work for the kernel which has to manage evictable ranges. I will update the
bug shortly and you guys can let me know how you feel about it before I send a
CL.

Purging JavaScript source files looks much harder to tackle. I will focus on
SharedBuffer first.

Powered by Google App Engine
This is Rietveld 408576698