Skip to content

perf: reduce reference-counting overhead and DBIx::Class warnings#871

Open
fglock wants to merge 2 commits into
masterfrom
perf/refcount-runtime-overhead
Open

perf: reduce reference-counting overhead and DBIx::Class warnings#871
fglock wants to merge 2 commits into
masterfrom
perf/refcount-runtime-overhead

Conversation

@fglock

@fglock fglock commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • register tracked scalar owners once after DESTROY-rescue handling instead of twice
  • remove redundant synchronized wrappers from the explicitly single-threaded scalar registry
  • remove empty reverse weak-reference buckets during unweaken
  • stop caught optional base::import failures from printing duplicate stderr diagnostics
  • align bundled DynaLoader and bytes file versions with their Java runtime versions
  • patch Exception::Class 1.45 generated subclasses to match the source file registered in %INC
  • add focused performance and version-consistency regression coverage

Performance

Three fresh JVM runs of dev/bench/benchmark_refcount_store.pl:

Revision Median CPU time
master (168466619) 2.71 s
this branch 2.41 s

This is an 11.1% reduction in CPU time for tracked reference stores after weaken() activates lifecycle bookkeeping.

The ordinary method benchmark remained approximately 2.35 CPU seconds on both revisions.

DBIx::Class warnings

t/00describe_environment.t no longer reports:

  • empty Getopt::Long::Descriptive base packages from caught optional-dependency probes
  • Params::ValidationCompiler generated exception version mismatches
  • DynaLoader or bytes runtime/file version mismatches

Exception::Class 1.45 still contains the upstream 1.1/1.45 mismatch; the CPAN distroprefs patch keeps the generated class version consistent with Exception/Class.pm while preserving its %INC registration.

Validation

  • standard Perl: prove src/test/resources/unit/core_module_file_versions.t
  • PerlOnJava: ./jperl src/test/resources/unit/core_module_file_versions.t
  • Exception::Class 1.45: 7 files, 86 tests, all successful
  • DBIx::Class t/00describe_environment.t: passed with none of the targeted warnings
  • make: successful
  • ./jcpan --jobs 8 -t DBIx::Class
    • 314 files
    • 13,121 tests
    • 818 seconds wall time
    • all tests successful

Safety notes

Two broader reference-counting optimizations were evaluated and rejected after unit-test regressions:

  • conditionally skipping temporary reachability roots
  • resetting the global weak-reference mode after the last weak reference cleared

The retained performance changes preserve the existing lifecycle state machine. The warning changes retain catchable base exceptions and validate file/runtime version consistency with a portable test that also passes on standard Perl.

Generated with Codex

fglock and others added 2 commits July 27, 2026 10:44
Register owned scalar references once after rescue handling, remove
unnecessary synchronization from the single-threaded weak scalar registry,
and release empty reverse weak-reference buckets on unweaken.

Add a focused tracked-store benchmark and document the measured 11.1%
median CPU improvement and full DBIx::Class validation.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Keep caught base::import failures from leaking duplicate stderr output,
align bundled core module versions with their runtime values, and patch
Exception::Class generated subclasses to match their registered source file.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
@fglock fglock changed the title perf: reduce tracked reference store overhead perf: reduce reference-counting overhead and DBIx::Class warnings Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant