Replace PVRManager::GetSensorState with lock-free shared memory structure (Eliminating sync IPC)

NEW
Assigned to

Status

()

Core
WebVR
5 months ago
4 months ago

People

(Reporter: kip, Assigned: kip)

Tracking

(Depends on: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [qf:p3])

Attachments

(1 attachment)

(Assignee)

Description

5 months ago
A lock-free structure in shared memory is more efficient than an IPC message queue, will help reduce latency, and will eliminate the sync IPC message in support of Bug 1344216.
(Assignee)

Updated

5 months ago
Blocks: 1344216
(Assignee)

Updated

5 months ago
See Also: → bug 1306493
Whiteboard: [qf:p3]
(Assignee)

Comment 1

5 months ago
For some background on the lock-free approach, see "Concurrent reading and writing" by Leslie Lamport:

http://dl.acm.org/citation.cfm?doid=359863.359878

This is applicable to VR headset state, such as positional tracking data, as it is updated by a single thread while being read by multiple threads.  Concurrent writing by multiple threads is not necessary.
(Assignee)

Comment 2

5 months ago
(In reply to :kip (Kearwood Gilbert) from comment #1)
> For some background on the lock-free approach, see "Concurrent reading and
> writing" by Leslie Lamport:
> 
> http://dl.acm.org/citation.cfm?doid=359863.359878
> 
> This is applicable to VR headset state, such as positional tracking data, as
> it is updated by a single thread while being read by multiple threads. 
> Concurrent writing by multiple threads is not necessary.

Specifically, I would apply the "General Readers/Writer Solution" for this application.
(Assignee)

Comment 3

5 months ago
We will also need to ensure that the solution is tolerant of preemption and does not result in crashing the content process if the GPU process is killed.
(Assignee)

Comment 4

5 months ago
(In reply to :kip (Kearwood Gilbert) from comment #3)
> We will also need to ensure that the solution is tolerant of preemption and
> does not result in crashing the content process if the GPU process is killed.
Pre-emption effects can be avoided by limiting the number of iterations attempting to get a new headset state in the reader.  When a valid state is read, it will be copied to the reader's non-shared memory.  In the event of the writer being pre-empted for an extended duration of time, the reader should fall back to the prior recorded sensor states.
(Assignee)

Comment 5

5 months ago
Created attachment 8853505 [details]
GeckoProfiler timeline showing PVRManager::GetSensorState sync IPC blocking between 5ms and 66ms
Kip, have you taken a look at, https://dxr.mozilla.org/mozilla-central/rev/0b255199db9d6a6f189b89b7906f99155bde3726/ipc/glue/SharedMemory.h? Could it have any help for us?
(Assignee)

Comment 7

4 months ago
(In reply to Daosheng Mu[:daoshengmu] from comment #6)
> Kip, have you taken a look at,
> https://dxr.mozilla.org/mozilla-central/rev/
> 0b255199db9d6a6f189b89b7906f99155bde3726/ipc/glue/SharedMemory.h? Could it
> have any help for us?
Yes, I think me may be able to use this class in our implementation.  It's nice to have some platform abstraction
(Assignee)

Updated

4 months ago
Depends on: 1362578
You need to log in before you can comment on or make changes to this bug.