-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Since Arcanization, we've been running into deadlocks at a pretty regular pace. This week's update of wgpu in Firefox exposed two new deadlocks which @nical has debugged and posted fixes for.
Before Arcanization, wgpu-core had a somewhat obscure rigging of tokens and types and traits ("oh my") such that acquiring locks in the wrong order would be a compile-time error. It wasn't well-documented, and people generally found it hard to understand. Arcanization removed this rigging, to cheers and rejoicing --- and we immediately started running into deadlocks. Some were sorted out before arcanization landed, but we've continued to find them since.
We should consider adding this static scaffolding back in --- accompanied by good global documentation for wgpu-core's locking discipline, to provide an explanation we can point to when people are confused.
Note that wgpu-core's locks post-arcanization bear little resemblance to the ones we had before. Previously, the lock hierarchy corresponded to resource types: Buffer
, BindGroup
, Device
, and so on. But now all Registry
s' RwLock
s are "leaf" locks - they're only held for short periods of time, without acquiring other locks (I think that's right), so they don't have interesting relationships with each other. Instead, we'll be establishing an ordering between the various fields of Device
like life_tracker
and temp_suspected
.
We'll have to think carefully about how SnatchLock
fits into the picture.