Reduce argument-container cleanup cost in call-heavy Perl code
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 領域
- backend, performance
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
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; targetMath::Gauss; distributionMath-Gauss-0.01; testt/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
574e32db7c29483f366d6b1b608b88eb39e8af28ran 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, andalmost;cdfcallspdf, andpdf/cdfconsume arguments withshift. - 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 throughBytecodeInterpreter.execute. - The relevant cleanup remains present on live master
f5352bb8d2e34dd6ad2d3bc0bd73818d250f8346:RuntimeCodereleases the argument-container owner and refreshes its cells;RuntimeArrayvisits each direct cell;RuntimeScalarreconciles ownership and searches for replacement owners.RuntimeCode.popArgsreleases 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.01suite 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.
- 主要語言
- Perl
- 星號
- 67
- 分支
- 9
- 平均合併
- 6 小時 45 分鐘
- 30 天內合併 PR
- 104
環境準備
- 提供 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
fglock/PerlOnJava 的其他 Issue
-
area:cpan-port area:performance bug
難度 2/5 1-3 小時 新手友好度 72/100
fglock/PerlOnJava#2230 ·
維護者通常 1 天內回覆
-
area:runtime documentation enhancement
難度 2/5 1-3 小時 新手友好度 72/100
fglock/PerlOnJava#1579 ·
維護者通常 1 天內回覆
-
area:backend area:cpan-port area:runtime bug
難度 4/5 3-5 天 新手友好度 72/100
fglock/PerlOnJava#2231 ·
維護者通常 1 天內回覆
-
area:parser area:runtime area:unicode bug
難度 5/5 一週以上 新手友好度 38/100
fglock/PerlOnJava#2228 ·
維護者通常 1 天內回覆
-
area:cpan-port area:runtime bug
難度 3/5 1-2 天 新手友好度 70/100
fglock/PerlOnJava#2227 ·
維護者通常 1 天內回覆
查看 fglock/PerlOnJava 的全部 Issue
相似的 Issue
-
Make logo .svg未關閉documentation
難度 2/5 1-3 小時 新手友好度 65/100
larchanka/ppc-code-ai-agent#38 ·
維護者通常 1 天內回覆
-
[doc] perlsub wrongly says that `"sub { ... }" creates a new subroutine each time it is executed'未關閉documentation Needs Triage
難度 2/5 1-3 小時 新手友好度 69/100
維護者通常 1 天內回覆
-
docs(api): /api/v3/external_sources spec is missing lc and section_title可能已有人在做 @subhwastaken 今天認領。 未關閉
難度 1/5 1-3 小時 新手友好度 82/100
openfoodfacts/openfoodfacts-server#15626 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 1/5 1-3 小時 新手友好度 67/100
LMS-Community/slimserver#1742 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 78/100