Skip to content

Conversation

@lbcheng888
Copy link
Contributor

  • Documented all ARC/ORC deterministic-release work, including IR generation changes (nimTraceClosure, mandatory attachedTrace),
    runtime support (TNimTypeV2, cyclebreaker.releaseGraph/thinout, lightweight nimTraceRef* stub), and async lifecycle fixes
    (callSoon, consolidated leak tests, new stress suites).
  • Published the verification matrix that was used to vet the new behavior (ARC/ORC runs, threaded scenarios, leak counters).

lbcheng888 and others added 6 commits October 16, 2025 08:39
…arc/orc

Add ARC/ORC regression for async callSoon closures
…eration changes (nimTraceClosure, mandatory attachedTrace),

    runtime support (TNimTypeV2, cyclebreaker.releaseGraph/thinout, lightweight nimTraceRef* stub), and async lifecycle fixes
    (callSoon, consolidated leak tests, new stress suites).
  - Published the verification matrix that was used to vet the new behavior (ARC/ORC runs, threaded scenarios, leak counters).
@Araq
Copy link
Member

Araq commented Oct 16, 2025

Most interesting. Can you give us more documentation please?

@lbcheng888
Copy link
Contributor Author

sure, b395500


proc unregisterCycle(s: Cell) =
# swap with the last element. O(1)
if s.rootIdx == 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fishy. Why can this happen now that we support thinOut?

Copy link
Contributor Author

@lbcheng888 lbcheng888 Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing and comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinOut only guarantees that the roots array is compact at the moment it runs.
During destructors or partial collections roots can be mutated again and the
cached rootIdx becomes stale (it can even drop to zero although the entry is
still present). With thinOut alone we can still reach unregisterCycle with an
invalid index. The fix recompacts roots on demand and rescans for the cell so
the removal is always correct.

lbcheng added 2 commits October 17, 2025 16:25
Destructors and partial collects can reshuffle the ORC roots array, leaving
entries with rootIdx <= 0 even though the cell remains tracked. The old
unregisterCycle treated that as already-unlinked and leaked the root.

Add an internal compactRoots helper that recomputes indices, let
unregisterCycle revalidate its slot (falling back to a scan if thin-out moved
the cell), and only then swap it with the tail.

Tests: testament/testament --nim:bin/nim c arc "--mm:arc"
       testament/testament --nim:bin/nim c arc "--mm:orc"
       nim c --gc:orc -d:nimThinout -r tests/arc/thamming_thinout.nim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants