WebKit Bugzilla
Attachment 341529 Details for
Bug 186064
: Add a version of JSVirtualMachine shrinkFootprint that runs when the VM goes idle
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
b-backup.diff (text/plain), 3.59 KB, created by
Saam Barati
on 2018-05-29 15:32:31 PDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Saam Barati
Created:
2018-05-29 15:32:31 PDT
Size:
3.59 KB
patch
obsolete
>Index: Source/JavaScriptCore/ChangeLog >=================================================================== >--- Source/JavaScriptCore/ChangeLog (revision 232275) >+++ Source/JavaScriptCore/ChangeLog (working copy) >@@ -1,3 +1,31 @@ >+2018-05-29 Saam Barati <sbarati@apple.com> >+ >+ JSVirtualMachine shrinkFootprint should run when the VM goes idle >+ https://bugs.webkit.org/show_bug.cgi?id=186064 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ shrinkFootprint was implemented as: >+ ``` >+ sanitizeStackForVM(this); >+ deleteAllCode(DeleteAllCodeIfNotCollecting); >+ heap.collectNow(Synchronousness::Sync); >+ WTF::releaseFastMallocFreeMemory(); >+ ``` >+ >+ However, for correctness reasons, deleteAllCode is implemented to do >+ work when the VM goes idle (no JS is running on the stack). This means >+ that if shrinkFootprint is called when JS is running on the stack, it >+ ends up freeing less memory than it could have if it waited to run until >+ the VM goes idle. >+ >+ This patch makes that change. I'm seeing a 10% footprint progression >+ when testing this against a client of the JSC API. >+ >+ * API/JSVirtualMachinePrivate.h: >+ * runtime/VM.cpp: >+ (JSC::VM::shrinkFootprint): >+ > 2018-05-29 Caio Lima <ticaiolima@gmail.com> > > [ESNext][BigInt] Implement support for "<" and ">" relational operation >Index: Source/JavaScriptCore/API/JSVirtualMachinePrivate.h >=================================================================== >--- Source/JavaScriptCore/API/JSVirtualMachinePrivate.h (revision 232275) >+++ Source/JavaScriptCore/API/JSVirtualMachinePrivate.h (working copy) >@@ -34,8 +34,12 @@ > /*! > @method > @discussion Shrinks the memory footprint of the VM by deleting various internal caches, >- running synchronous garbage collection, and releasing memory back to the OS. For this >- to free as much memory as possible, do not call this when JavaScript is running on the stack. >+ running synchronous garbage collection, and releasing memory back to the OS. Note: this >+ API waits until no JavaScript is running on the stack before it frees any memory. It's >+ best to call this API when no JavaScript is running on the stack for this reason. However, if >+ you do call this API when JavaScript is running on the stack, the API will wait until all JavaScript >+ on the stack finishes running to free memory back to the OS. Therefore, calling this >+ API may not synchronously free memory. > */ > > - (void)shrinkFootprint; // FIXME: Annotate this with NS_AVAILABLE: <rdar://problem/40071332>. >Index: Source/JavaScriptCore/runtime/VM.cpp >=================================================================== >--- Source/JavaScriptCore/runtime/VM.cpp (revision 232275) >+++ Source/JavaScriptCore/runtime/VM.cpp (working copy) >@@ -779,12 +779,14 @@ void VM::deleteAllCode(DeleteAllCodeEffo > > void VM::shrinkFootprint() > { >- sanitizeStackForVM(this); >- deleteAllCode(DeleteAllCodeIfNotCollecting); >- heap.collectNow(Synchronousness::Sync); >- WTF::releaseFastMallocFreeMemory(); >- // FIXME: Consider stopping various automatic threads here. >- // https://bugs.webkit.org/show_bug.cgi?id=185447 >+ whenIdle([=] () { >+ sanitizeStackForVM(this); >+ deleteAllCode(DeleteAllCodeIfNotCollecting); >+ heap.collectNow(Synchronousness::Sync); >+ WTF::releaseFastMallocFreeMemory(); >+ // FIXME: Consider stopping various automatic threads here. >+ // https://bugs.webkit.org/show_bug.cgi?id=185447 >+ }); > } > > SourceProviderCache* VM::addSourceProviderCache(SourceProvider* sourceProvider)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186064
:
341529
|
341536
|
341548