Skip to content

35% of performance going to #available(..., *) (__isPlatformVersionAtLeast) #84787

@MahdiBM

Description

@MahdiBM

Motivation

I'm benchmarking and profiling my package, and apparently 35% of the time is spent in __isPlatformVersionAtLeast.

Image

I have a bunch of #available(swiftIDNAApplePlatforms 26, *) / #available(swiftIDNAApplePlatforms 13, *)s in the code.
These are defined as:

.enableExperimentalFeature(
    "AvailabilityMacro=swiftIDNAApplePlatforms 26:macOS 26, iOS 26, tvOS 26, watchOS 26, visionOS 26"
),
.enableExperimentalFeature(
    "AvailabilityMacro=swiftIDNAApplePlatforms 13:macOS 13, iOS 16, tvOS 16, watchOS 9"
),

Proposed solution

Sounds to me implementing some caching mechanism can solve the issue?

Alternatives considered

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureA feature request or implementationtriage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions