Skip to content

scoped_enum's abuse of get_property #524

@luke-kiernan

Description

@luke-kiernan

Running @snoop_invalidations on using PowerSimulations, I see the following:

 inserting getproperty(::Type{FACTSOperationModes}, sym::Symbol) @ PowerSystems.FACTSOperationModesModule ~/Documents/julia/Sienna/psy5/InfrastructureSystems.jl/src/utils/utils.jl:370 invalidated:
   backedges: 1: superseding getproperty(x::Type, f::Symbol) @ Base Base_compiler.jl:48 with MethodInstance for getproperty(::Type, ::Symbol) (1 children)
              2: superseding getproperty(x::Type, f::Symbol) @ Base Base_compiler.jl:48 with MethodInstance for getproperty(::DataType, ::Symbol) (387 children)
[repeats once for every scoped enum definition]

That second child has 387 invalidations. And that happens for every ScopedEnum! I'll see if I can find a way to quantify the pre-compilation impact of this...but at the very least, this is bad.

If we simply replaced ACBusTypes.REF with ACBusTypes._name2value[:REF], then it'd go away. Still, it'd be nice to have some more concise syntax. Maybe we could make something like ACBusTypes(REF) work.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions