Skip to content

private field access is ~1.5× public (residual after #11864/#11913/#11954) #11791

Open

Description

@proggeramlug

Private brand markers are stored as own keys on instances, so every instance of a class with #private members leaves the class's birth shape. Method calls on such instances then miss the class-shape fast path.

  • Cost: a method call on an instance of a class with private members is 7,540 instructions on main. A per-site extra-shape cache (shape-campaign method-call lane) brings it to 1,844, which works around the miss without removing the cause.
  • Fix (charter): make the private brand a shape fact, so the class's birth shape carries the brand, instead of an own key. Brand checks (#x in o, private field/method access) then compare the shape or its brand fact, and instances stay on the birth shape.

This lives in the class-template / birth-shape area that #11780 (template-owned final shapes for class objects and prototypes) builds. It will follow as its own PR on top of #11780.

Activity

  1. proggeramlug commented on Oct 4, 2026

    @proggeramlug
    ContributorAuthor

    Progress in #11864: private brands and private fields are now facts of the object shape (private rows 4–7× faster; tsc −0.06%, Zod +0.215%). Leaving open unless the author confirms this fully meets the issue's target.

  2. proggeramlug commented on Oct 4, 2026

    @proggeramlug
    ContributorAuthor

    More progress in #11913: private fields are typed slots of the class layout. private 447 → 331, field_rw 239 → 169, method_call 273 → 188 instructions; tsc flat, Zod −0.055%. The private row is still 1.5× public; leaving open.

  3. proggeramlug commented on Oct 8, 2026

    @proggeramlug
    ContributorAuthor

    Narrowing this issue's scope: the stated cause (the brand as an own key) is fixed by #11864 (private brands and fields are shape facts), #11913 (typed slots) and #11954 (a mint pays nothing for brands it doesn't carry). The gap tests test_gap_11791_* are on main.

    Remaining: private field access is still about 1.5× the cost of public field access. This issue now tracks that gap.

  4. changed the title [-]Private brands as own keys push every instance off the class birth shape (method calls 7.5k instructions)[/-] [+]private field access is ~1.5× public (residual after #11864/#11913/#11954)[/+] on Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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