Skip to content

Research: lock several lists exactly so functions with 3+ list parameters compile on 3.15t (nbody) #255

Open

Description

@b-re-w

User decision (2026-10-17): research option (C) for the nbody regression from #209.

Since #209, a function taking 3 or more list parameters stays interpreted on 3.15t: copy-in to write-back must hold the lists' locks, and CPython's critical-section API covers only 1 or 2 objects (nesting a third suspends the outer one under contention). nbody's offset_momentum (4 lists) and advance/energy (7) went from 31x to 1x.

Options considered: (A) per-list locks only at copy-in and write-back, which can lose another thread's concurrent element writes (a result no CPython interleaving produces); (B) keep refusing (current, identity kept); (C) lock every list exactly, e.g. take each list's internal mutex in address order. The user chose to research (C). Risks to establish: reliance on CPython internal fields (ob_mutex), self-deadlock with re-entrant critical sections, GC stop-the-world interaction.

Until (C) is settled, (B) stays. Done when: a design note states whether (C) is sound on 3.15t (with evidence: TSan / stress tests that fail on a broken variant), and if so it is implemented and nbody compiles again with identity kept.

Activity

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