Skip to content

Remove reachability-based memory sweeps from PerlOnJava #2043

Open

Description

@fglock

Goal

Remove reachability-based lifecycle decisions and memory sweeps. Perl strong references must use explicit owner slots with balanced acquisition and release. Historical origin: #1649.

Current checkpoint — 2026-11-21

PR #1938 remains open at 75dd7d542f1f86bff930beb1c5779be74fa27955, targets master, is DIRTY against current master, and has no human review. The tested local continuation is on wip/issue2043-handoff-20261121-154515, with HEAD at aebe3b0742 and uncommitted changes in the owner-ledger runtime and design checkpoint. This local branch remains recovery work and is not on the PR. The checkout is not ready for UAT.

The current working tree passes nice -n 19 timeout 900 make in 8m50 (/private/tmp/issue2043-owner-ledger-full-make.log), covering all five unit shards, Joni, and home integration. The shard-0 gate passed all 1,681 tests after fixing owner-slot release paths and async foreach source restoration. The candidate's direct lifecycle regressions pass on JVM and interpreter: eval/die destruction order 10/10, nested aggregate LIFO 2/2, hash list assignment 5/5, owner trace 3/3, and interpreted foreach source lifetime 7/7. make check-links passes with 0 errors.

DBIx::Class acceptance is still outstanding because DBIC_CLASS_TEST_ROOT is unset. The three diamond-prefetch tests skip cleanly in this environment; their earlier focused candidate runs passed, but must be repeated with DBIx::Class available. Moo and Template Toolkit also need focused retests against this latest lifecycle candidate. Do not publish this local branch directly: reconcile it with PR #1938 in an isolated worktree and validate that exact PR candidate before updating the PR.

Allocation minimization plan

Allocation reduction is a completion requirement for sweep removal alongside lower scan cost and correct Perl lifetime behavior. Keep per-frame LIFO cleanup and the explicit owner ledger; use maintained O(1) owner-kind counts for common yes/no checks and retain identity indexes only where identities are needed. Reuse lazy per-frame queues, recursive-release worksets, and cleanup-target probe queues/visited sets across roots instead of allocating a collection per candidate element. The focused chart test's probe workset initializations fell from one per 499 calls to 125 reusable worksets, about 75% fewer for that path. The duplicate direct weak-slot pass was folded into the probe.

The next implementation step is to release the dying aggregate's outgoing owner slots directly, avoiding nested target pre-scans and repeated incoming-owner ledger scans while preserving shared-owner, weak-reference, and destructor-rescue behavior. Track owner-slot visits, pre-scan roots/worksets, queue growth, and append/drain counts separately. Use paired JFR and elapsed-workload measurements on the same CPAN target; the short current recordings are diagnostic evidence only, not a speedup claim. Keep changes only when allocation and scan costs both improve and the hash, array, scalar-reference, and nested-frame regressions pass.

Validation

Earlier merged UAT candidate

  • nice -n 19 timeout 1800 make passes on source commit 5c011dfa0e in 9m36 (/private/tmp/issue2043-merged-uat-make.log).
  • make check-links passes with 855 links checked and 0 errors (/private/tmp/issue2043-merged-uat-check-links-current.log).
  • The UAT launcher reports 5c011dfa0e; the smoke command prints UAT_OK.
  • dev/modules/dbix_failed_connect_releases_handle.t passes 3/3 and dev/modules/dbix_failed_connect_releases_storage.t passes 4/4 on JVM and interpreter; system Perl validation is recorded in the design handoff.
  • On the merged candidate, DBIx t/storage/error.t passes 49/49 with no leaks. t/storage/txn.t has one exception line-reporting mismatch at assertion 89, present before the ownership fix; it reports no leaked references, while system Perl passes 128/128. The interpreter CPAN attempts previously hit their 300-second limits.
  • The full eight-target make test-cpan-release-acceptance remains incomplete. The prior run reached DBIx failures and ended before Excel finished; the isolated Excel profiling run below was deliberately stopped after capturing JFR and is not a module pass.
  • Current hosted checks for PR head 75dd7d542f1f86bff930beb1c5779be74fa27955 pass; the PR is open and has no human review recorded.

Current local candidate

  • nice -n 19 timeout 900 make passes on the current tested working tree in 8m50 (/private/tmp/issue2043-owner-ledger-full-make.log).
  • All five Java/Perl unit shards, Joni tests, and home integration tasks completed successfully. The previously failing async-await owner-depth cases and owner-slot tests pass in this run.
  • Focused eval/die, nested aggregate destruction, list-assignment, owner-trace, and interpreted foreach source lifetime tests pass on JVM and interpreter; complete outputs are under /private/tmp/issue2043-*-final-owner-fix.log.
  • make check-links passes with 0 errors. The current source diff is not committed or on PR Remove memory sweeps through explicit Perl owner slots (#2043) #1938.
  • The full DBIx::Class, Moo, Template Toolkit, and complete eight-target CPAN release-acceptance gates remain required on the reconciled immutable PR candidate. The fork failure remains waived by the user's prior direction.

Remaining work

  1. Replace nested cleanup-target pre-scans and repeated incoming-owner checks with processing of the exact outgoing owner slots of dying arrays and hashes. Preserve weak observers, live shared aggregates, scalar-reference semantics, and destructor rescue.
  2. Measure scan visits, workset and queue allocations, sampled allocations, and elapsed time on the same Excel::Writer::XLSX workload; require paired evidence before claiming a broad speedup.
  3. Run focused regressions for the previously observed Moo, Template Toolkit, and DBIx failures, then nice -n 19 make and the complete eight-target CPAN release-acceptance gate on one immutable source candidate. Stop after an actionable failure, fix it before continuing, and rerun required gates on the resulting candidate. The fork failure remains waived by the user.
  4. Reconcile the tested local candidate with PR Remove memory sweeps through explicit Perl owner slots (#2043) #1938, publish only after required gates pass, and wait for human review. Do not mark the checkout UAT ready or merge before final evidence.

After #2043 lands, resume #2037 archive-lifetime and #2034 localized-STDERR work separately.

Activity

  1. added
    enhancement
    area:memory
    area:runtime
    area:backend
    on Nov 12, 2026
  2. fglock commented on Nov 12, 2026

    @fglock
    OwnerAuthor

    Superseded by the current #2043 issue-body handoff. That handoff contains the active scope, evidence, branch status, blockers, and next actions.

  3. fglock commented on Nov 12, 2026

    @fglock
    OwnerAuthor

    While triaging #2034/#2037, I found two cases that intersect the active ownership migration:

    Could you reconcile #2037's released-parser/DATA-handle case with the current owner-slot work and advise when the #2034 typeglob-assignment path is safe to split or resume? I recorded both issue checkpoints with the reproducer matrix.

  4. fglock commented on Nov 12, 2026

    @fglock
    OwnerAuthor

    Related deferral: Data::Alias porting is tracked in #1990. Its aliasing behavior depends on the owner-accounting and scope-lifetime work in this issue, so implementation is deferred until that work is ready. The independent Safe, strict module-loading, and tainted eval fixes are in PR #2044; that PR does not implement Data::Alias.

  5. 109 remaining items

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

    area:backendarea:memoryarea:runtimeenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions