Consider no longer directly associating Shmem instances with actors
Categories
(Core :: IPC, enhancement, P2)
Tracking
()
People
(Reporter: nika, Assigned: nika)
References
(Regressed 1 open bug)
Details
Attachments
(1 file)
With this new approach, Shmem
instances will now have their handles transferred inline within messages as attachments, rather than being associated with their actors and sent in separate messages.
This has a few advantages:
- The implementation is much simpler
- Releasing all references to a
Shmem
will automatically destroy it by RAII, rather than leaking the shared memory region until the toplevel actor is destroyed, removing the need for types likeRaiiShmem
. - This allows re-transmitting
Shmem
instances to another process, as we don't close the shared memory region handle upon receiving it.
But also has a disadvantage that because we keep alive the shared memory region's handle until the shmem is destroyed, so that it can be re-transmitted, we may end up using more FDs or HANDLEs while running.
This bug intentionally doesn't change or simplify callsites, removing APIs like RaiiShmem
, in order to make it easier to revert if this causes issues on platforms like Linux due to FD exhaustion. If we don't run into increased resource exhaustion problems, we can make these changes in a follow-up.
Assignee | ||
Comment 1•11 months ago
|
||
With this new approach, Shmem instances will now have their handles
transferred inline within messages as attachments, rather than being
associated with their actors and sent in separate messages.
This has a few advantages:
- The implementation is much simpler
- Releasing all references to a Shmem will automatically destroy it by
RAII, rather than leaking the shared memory region until the toplevel
actor is destroyed, removing the need for types like RaiiShmem. - This allows re-transmitting Shmem instances to another process, as we
don't close the shared memory region handle upon receiving it.
But also has a disadvantage that because we keep alive the shared memory
region's handle until the shmem is destroyed, so that it can be
re-transmitted, we may end up using more FDs or HANDLEs while running.
This patch intentionally doesn't change or simplify callsites, removing
APIs like RaiiShmem, in order to make it easier to revert if this causes
issues on platforms like Linux due to FD exhaustion. If we don't run
into increased resource exhaustion problems, we can make these changes
in a follow-up.
Depends on D140009
Pushed by nlayzell@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/0d23532d6a49 Don't keep alive Shmem shared memory regions on IProtocol, r=ipc-reviewers,jld
Comment 3•9 months ago
|
||
bugherder |
Comment 4•9 months ago
|
||
Backed out as requested.
Backout link: https://hg.mozilla.org/integration/autoland/rev/88a76c0a8d1cd349786eb1610cfa2f10907d7a1c
Updated•9 months ago
|
![]() |
||
Comment 5•9 months ago
|
||
Comment 6•9 months ago
|
||
There's a r+ patch which didn't land and no activity in this bug for 2 weeks.
:nika, could you have a look please?
If you still have some work to do, you can add an action "Plan Changes" in Phabricator.
For more information, please visit auto_nag documentation.
Assignee | ||
Comment 7•9 months ago
|
||
There was a regression from the change and we still don't have any idea as to what caused it, so there's not a ton of immediate action we can take.
Assignee | ||
Comment 8•9 months ago
|
||
Err actually nevermind, wrong patch. This is blocked on bug 1767514 (and potentially other changes) for now.
Updated•8 months ago
|
Assignee | ||
Comment 9•7 months ago
|
||
We still need the ffmpeg update to land something like this, and we may want to also be a bit more clever around the media code etc.
Assignee | ||
Comment 10•7 months ago
|
||
(also around graphics potentially)
Comment 11•5 months ago
|
||
Nika, I've updated our vendored ffmepg copy to a recent version, containing the bug fix that was needed for this to not crash, maybe we can reland this?
Updated•23 days ago
|
Assignee | ||
Comment 12•9 days ago
|
||
We're slightly concerned about potential performance issues which might occur due to GMP code expecting the existing behaviour's performance characteristics, so we've been holding off on landing something like this directly. Instead, we've been adding some new Shmem types like BigBuffer
or the flexible API for unsafe shred memory from bug 1795311 which are hopefully better suited for the existing uses of Shmem
. We might want to then refactor the code out of the core IPC layer, and make it something which GMP deals with directly instead.
Description
•