Reduce argument-container cleanup cost in call-heavy Perl code

Offen
#2,232 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
java, perl
Bereich
backend, performance

Rechercherichtung

Start with the call-frame cleanup in src/main/java/org/perlonjava/runtime/runtimetypes/RuntimeCode.java, then trace the cell visits in RuntimeArray.java and owner reconciliation in RuntimeScalar.java. Read the existing tests around argument containers, ownership, aliasing, and destruction, and add deterministic coverage for repeated calls with shift. Done means the requested backend checks and matched current-parent versus candidate measurements pass, and the unchanged Math-Gauss suite completes without the observed delay.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

area:ownership area:performance area:runtime bug

Summary

Math-Gauss 0.01's t/Math-Gauss.t passes under standard Perl but exceeds the PerlOnJava CPAN test timeout. A bounded reproduction and two live JVM thread samples point to high CPU cost in per-call argument-container ownership cleanup: releasing a Perl argument container reconciles its cells, and argument extraction also exercises the same container-owner bookkeeping. This is a performance failure, not evidence of non-termination.

Evidence

  • CPAN random-tester run: 20261129-192130-74689; target Math::Gauss; distribution Math-Gauss-0.01; test t/Math-Gauss.t.
  • The archived run record reports TIMEOUT (soft limit 240s exceeded; no output for 232s) while invoking the test harness. The harness reports the test file only after that file completes, so the absence of intermediate TAP is expected.
  • The paired standard-Perl oracle used Perl 5.42.2 and passed the complete suite: 1 file / 101 tests, 0.52 CPU seconds.
  • A faithful bounded rerun with PerlOnJava 5.44.1, Temurin 24.0.2, macOS arm64, source commit 574e32db7c29483f366d6b1b608b88eb39e8af28 ran for 300 seconds and exited 124 with no test output. The target JVM sustained approximately one CPU core. Other CPAN work was active on the shared host during this rerun, so the elapsed time is not a clean benchmark; it does reproduce the CPU-bound timeout behavior.
  • The test's two numerical comparison loops each have 244,610 parameter combinations. Across both loops, the test makes about 1.96 million Perl subroutine calls to pdf, cdf, and almost; cdf calls pdf, and pdf/cdf consume arguments with shift.
  • At about 58 seconds, a live JVM stack was in RuntimeArray.shift → RuntimeArrayElementList.removeFirst → RuntimeScalar.reconcileContainerOwnerAfterMutation.
  • At about 93 seconds, a second stack was in RuntimeCode.popArgs → releaseArgumentContainerOwners → ArgumentContainerOwner.release → refreshUntrackedCellsAfterContainerTransfer → RuntimeArray.refreshUntrackedElementOwnersAfterTransfer → RuntimeScalar.reconcileContainerOwnerAfterAggregateTransfer / removeContainerOwnerTracking. The stack entered through BytecodeInterpreter.execute.
  • The relevant cleanup remains present on live master f5352bb8d2e34dd6ad2d3bc0bd73818d250f8346: RuntimeCode releases the argument-container owner and refreshes its cells; RuntimeArray visits each direct cell; RuntimeScalar reconciles ownership and searches for replacement owners. RuntimeCode.popArgs releases these owners on call-frame exit.

The exact CPAN reproduction was run on 574e32db7c, not again on the latest f5352bb8d2 master artifact. The source inspection confirms the implicated path still exists there. A parent-versus-current performance comparison and a forced interpreter-only comparison remain undone.

Suspected cause

Call-frame teardown repeatedly reconciles argument-array cells even in a workload dominated by short-lived calls and shift-based argument extraction. That path performs container membership and owner-ledger work for each affected scalar; at this call volume, the bookkeeping dominates the small Gaussian formulas. The thread samples support this cause, but a profile with inclusive/exclusive costs and deterministic work counters should guide the fix.

Related: #1863 tracks project-wide throughput work. Its current scope does not record this argument-container cleanup path or the Math-Gauss workload. Issues #1860 and #1950 concern different reachability-walk paths. PR #1938 merged the explicit-owner migration; this report describes the still-present call-cleanup cost and does not claim that PR alone introduced it.

Acceptance criteria

  • Add deterministic coverage or counters for argument-container cleanup under repeated calls and shift; assert redundant reconciliation/work is bounded without using elapsed time as a test assertion.
  • Validate any Perl-level regression with standard Perl first, then run focused coverage on JVM and interpreter while preserving argument aliasing, owner release, weak-reference, and destruction behavior.
  • Rerun the unchanged Math-Gauss-0.01 suite on current master and the fixed candidate. Record both backends and bounded outcomes; the suite should complete without the observed multi-minute CPU-bound delay.
  • Capture CPU/allocation evidence and a matched current-parent versus candidate timing with equal work and checksums. Do not claim a general speedup from this single CPAN workload.
Vorherrschende Sprache
Perl
Sterne
67
Forks
9
Ø Merge
6 Std. 45 Min.
Gemergte PRs (30 T.)
104

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus fglock/PerlOnJava

Alle Issues in fglock/PerlOnJava

Ähnliche Issues

Weitere Issues zu Perl

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.