Repository navigation
Port Devel::Size for PerlOnJava #1880
Description
Summary
Port Devel::Size for PerlOnJava so CPAN modules that use it as a runtime dependency can load and estimate Perl object sizes on the JVM and interpreter backends.
Devel::Size is currently absent from PerlOnJava's bundled modules. A minimal use fails during module lookup:
use Devel::Size qw(size total_size);The missing module blocks consumers that declare it as a runtime prerequisite. One concrete consumer observed during CPAN testing is DBG 0.4.1.
Upstream behavior and expected API
The current CPAN release is Devel-Size 0.87, released 2026-03-31. Its Perl wrapper exports size and total_size on request (and via the :all tag), and exposes $Devel::Size::warn and $Devel::Size::dangle controls. The implementation currently loads XS and traverses Perl values, including aggregate/reference structures.
On PerlOnJava, size($value) should return a useful estimate for the value's PerlOnJava representation, and total_size($value) should estimate the reachable structure while counting shared referents once and handling cycles. Estimates should be stable enough for comparisons and diagnostics, but need not match Perl's C allocator byte-for-byte. The module should load without XS and work on both execution backends.
Porting scope
- Add a bundled
Devel::SizePerl module and Java runtime implementation, following the existing PerlOnJava module-registration pattern. - Traverse PerlOnJava runtime values and account for scalars, arrays, hashes, references, code/glob-like values where supported, shared references, and cyclic graphs.
- Preserve the documented exports and warning/dangling-reference controls where applicable; document any deliberate limitations of the Java object model.
- Adapt the upstream tests as project-owned tests, including recursion/cycle and shared-reference cases, and run them on system Perl before relying on them for PerlOnJava behavior.
- Document that these values estimate PerlOnJava-managed object footprints, not process RSS or exact native Perl allocation sizes.
Reverse-dependency estimate
MetaCPAN's reverse-dependency endpoint currently reports 24 distinct distributions mentioning Devel::Size across prerequisite phases. Filtering the latest release metadata to direct runtime requires gives an estimated 22 direct runtime dependants; 6 of those latest releases were updated in the two years before 2026-10-24. These are distribution-level metadata counts, not a count of active users or all transitive consumers. The runtime dependants include diagnostic, profiling, benchmark, GUI, and application distributions.
Sources: MetaCPAN reverse dependencies API and MetaCPAN API documentation.
Acceptance criteria
use Devel::Size qw(size total_size)succeeds without an installed nativeDevel::Sizeon both JVM and interpreter backends.sizeandtotal_sizereturn non-negative numeric estimates for supported values; aggregate size grows as contained data grows.- Shared referents are not counted repeatedly by
total_size, and cyclic structures terminate. - Export/tag behavior and documented controls have focused regression coverage, with unsupported behavior documented.
- The adapted project-owned tests pass with system Perl as an oracle where the semantics are standard Perl behavior, and on both PerlOnJava backends.
Related: #1873 (a separate FileHandle/IO::Seekable porting issue whose CPAN investigation also encountered this missing prerequisite).
Activity
fglock commentedon Oct 24, 2026
Follow-up: the adjacent
Encode.pmXSLoaderonBOOTcompatibility failure has been fixed in PR #1882, which is awaiting CI. This does not implementDevel::Size: the module is still not bundled and its size-estimation API remains unavailable, so this porting issue remains open.fglock commentedon Oct 24, 2026
Update: PR #1882 has merged as
674f1ec, with Windows and Ubuntu CI passing. This resolves the adjacent Encode XSLoaderonBOOTcompatibility failure.Devel::Sizeitself is still not bundled and its size-estimation API remains unavailable, so this porting issue remains open.fglock commentedon Oct 30, 2026
State: complete
Agent/session: Codex API session 2026-10-30
Scope: #1880, bundle Devel::Size with Java-backed JVM footprint estimates, tests, and documentation
Work: PR #1937 merged from feature/devel-size-1880
Result: Devel::Size 0.87 bundled; uses JOL ClassLayout for shallow scalar/payload sizing and GraphLayout for reachable graph totals; exports size/total_size on request and via :all; retains $warn/$dangle as documented compatibility variables; includes tests for growth, shared references, cycles, and exports; updates module reference and Work in progress changelog.
Evidence: PR #1937 merged at 4a5c337; current-head CI run 41091138044 passed on Windows and Ubuntu; issue #1880 is closed.