Skip to content

Idea for reducing enum parsing/formatting overheads #76398

@stephentoub

Description

@stephentoub

Copying @jkotas' feedback here so we don't lose track of it:
#76162 (review)

If you are looking into squeezing more cycles from Enum formatting and parsing, you can try switching on underlying enum CorElementType as the very first thing (using a cached CorElementType for non-generic methods and intrinsic method for the generic methods), and then dispatch to specialized code for each underlying CorElementType.

The benefits of this approach should be:

  • Avoid conversions to / from ulong type
  • The array of values will be 2x smaller for the most common int underlying type
  • Eliminate generic code duplication for Enum methods since the switch will completely evaporate and the rest of the code will be all shared between different Enum types

This would mimic what the high-performance Enum packages out there use, except they typically do that using generic code stamping of the whole thing. Sharing the code per CorElementType should solve that problem.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions