Bug 233401

Summary: Avoid allocating and copy memory from a SharedMemory into a SharedBuffer
Product: WebKit Reporter: Jean-Yves Avenard [:jya] <jean-yves.avenard>
Component: Page LoadingAssignee: Jean-Yves Avenard [:jya] <jean-yves.avenard>
Status: RESOLVED FIXED    
Severity: Normal CC: beidson, eric.carlson, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=233363
Bug Depends on: 230329    
Bug Blocks: 233030    
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Jean-Yves Avenard [:jya]
Reported 2021-11-20 15:19:21 PST
In bug 230329 ; we added the possibility to wrap a SharedMemory into a SharedBuffer with the method SharedMemory::createSharedBuffer() : it avoid having to allocate memory and perform a new copy. It also helps in decreasing the amount of memory allocated in the GPU Process (limited to 200MB) as the memory is counted by jetsam as being linked to the content process. So rather than doing: ``` auto buffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryBuffer->data()), bufferSize); ``` which will copy the SharedMemory into a vector inside the SharedBuffer we can do: ``` auto buffer = sharedMemoryBuffer->createSharedBuffer(bufferSize); ``` and kill two birds with one store.
Attachments
Patch (11.44 KB, patch)
2021-11-21 02:20 PST, Jean-Yves Avenard [:jya]
no flags
Patch (12.46 KB, patch)
2021-11-21 14:09 PST, Jean-Yves Avenard [:jya]
no flags
Patch (12.44 KB, patch)
2021-12-01 17:24 PST, Jean-Yves Avenard [:jya]
no flags
Radar WebKit Bug Importer
Comment 1 2021-11-20 15:20:01 PST
Jean-Yves Avenard [:jya]
Comment 2 2021-11-21 02:20:47 PST
Jean-Yves Avenard [:jya]
Comment 3 2021-11-21 14:09:45 PST
Created attachment 444932 [details] Patch make ShareableResource use thread-safe refcount. Previously CFAllocatorContext’s would have always called the deallocator on the main thread
Eric Carlson
Comment 4 2021-12-01 15:52:18 PST
Comment on attachment 444932 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=444932&action=review > Source/WebKit/ChangeLog:10 > + SharedMemory::createSharedBuffer instead. Nit: using SharedMemory::createSharedBuffer instead of ...?
Jean-Yves Avenard [:jya]
Comment 5 2021-12-01 17:24:49 PST
EWS
Comment 6 2021-12-01 18:12:46 PST
Committed r286408 (244754@main): <https://commits.webkit.org/244754@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 445643 [details].
Note You need to log in before you can comment on or make changes to this bug.