Closed bushrat011899 closed 11 months ago
Is this a performance problem in practice (root of all-evil and all that)?
Doesn't the Internal
suffix mean it's considered private Bevy API?
Is this a performance problem in practice (root of all-evil and all that)?
To my knowledge, no, and I'd be surprised if any benchmark could even reliably measure any difference. My goal is just to simplify that part, since the Arc
and RwLock
don't provide any benefits in this case.
Doesn't the
Internal
suffix mean it's considered private Bevy API?
Not in this case. The reason for TypeRegistry
and TypeRegistryInternal
is that because of how scenes and assets are loaded, the TypeRegistry
needs to be accessed in a way that's only possible through Arc<RwLock<...>>
. For bevy_ggrs
, that requirement does not exist. If you look at the definition for TypeRegistry
in Bevy, you'll see a comment explaining the eventual desire to remove it entirely in favour of TypeRegistryInternal
. You can even see it through the type names, as TypeRegistryInternal
is actually named TypeRegistry
, while TypeRegistry
is named TypeRegistryArc
.
Objective
The
RollbackTypeRegistry
contains aTypeRegistry
, which itself is a thin wrapper aroundTypeRegistryInternal
, but through anArc<RwLock<...>>
. This indirection adds overhead to every interaction with the rollback type registry for no particular reason and should be removed. As a bonus, removing it would remove the need for theparking_lot
dependency (still in the graph because of Bevy)Solution
Stored
TypeRegistryInternal
inside theRollbackTypeRegistry
instead and removed lock acquisition code.