Skip to content

subscriber: rewrite Registry to use static arrays #2230

@davidbarsky

Description

@davidbarsky

Feature Request

Crates

  • tracing-subscriber

Motivation

The typemap-based used by the Registry's to store extensions is a typemap that erases types, places them into a Box, and stores the box into a HashMap. While this makes it easy to get started with the Registry, this approach does have a noticeable overhead when used in contexts such as profiling (e.g., bevyengine/bevy#4892).

Proposal

Instead of using a HashMap for extensions, Layer types would be required to pre-declare extension types they'd be storing in the Registry and use arrays to store extensions, avoiding the boxing (and potentially, the HashMap lookup).

Alternatives

Don't do this, but I think that the performance benefits of this are non-trivial.

(Sorry this issue is a bit short, I had to run and most of the implementation details will be discovered while creating this API.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions