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

Đang mở
#2,232 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java, perl
Lĩnh vực
backend, performance

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
Perl
Star
67
Fork
9
Merge trung bình
6 giờ 45 phút
Pull request đã merge (30 ngày)
104

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của fglock/PerlOnJava

Tất cả issue của fglock/PerlOnJava

Issue tương tự

Thêm issue về Perl

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.