perf: split BytecodeInterpreter.execute for default C2 compilation

オープン
#2,093 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java

調査の方向性

Start by reading BytecodeInterpreter.execute(SuspendedInterpreterFrame) and the profiling skill at .agents/skills/profile-perlonjava/SKILL.md; use dev/bench/benchmark_eval_string.pl to reproduce the eval STRING workload. Split the dispatch path while preserving opcode behavior and JVM/interpreter parity, then check HotSpot diagnostics, project tests, and the make gate. Compare randomized paired runs against the exact parent and check representative workloads and startup cost; done means default flags produce effective C2 compilation with a measured improvement and no material regression.

索引モデルが issue の本文から書いたものです。

説明

area:backend enhancement

Summary

Split BytecodeInterpreter.execute(SuspendedInterpreterFrame) into smaller dispatch/handler methods so HotSpot's default C2 policy can optimize the eval STRING interpreter path without globally enabling compilation of huge methods.

This is follow-up work to eval performance investigations on master. PR #2059 contains allocation and frame-pooling changes, but its performance effect was small and did not address the dispatch method's JIT compilation limit.

Evidence

On master commit 3e725aa6e1 (Temurin 24.0.2, Apple Silicon), async-profiler sampling of dev/bench/benchmark_eval_string.pl showed BytecodeInterpreter.execute as the largest CPU leaf (199 of 1,694 samples, C1), followed by StatementResolver.parseStatement (59) and CompileAssignment.compileAssignmentOperator (48).

HotSpot compilation diagnostics report the private execute(SuspendedInterpreterFrame) method at 23,790 bytecodes. The default DontCompileHugeMethods policy prevents C2 from optimizing this hot dispatch path; the log also reports it as too large to inline.

As a diagnostic, disabling that policy with -XX:-DontCompileHugeMethods caused the 23,790-byte method to reach C2 level 4. Five randomized default/flag pairs on the same master JAR measured:

Default C2 enabled Speedup
52.4k/s 102.7k/s 1.96x
60.7k/s 98.1k/s 1.62x
65.7k/s 98.3k/s 1.50x
71.2k/s 106.9k/s 1.50x
73.2k/s 114.3k/s 1.56x

Each run executes one million iterations of dev/bench/benchmark_eval_string.pl. The geometric mean paired gain is about 1.60x. Host load caused variance in both modes; all five pairs favored C2.

Goal

Reduce the dispatch method's bytecode size enough that the normal JVM policy compiles its hot path effectively. Prefer extracting cold opcode families and keeping common eval opcodes on a direct, JIT-friendly path. Keep opcode semantics, exception behavior, interpreter state, and JVM/interpreter parity unchanged.

The global -XX:-DontCompileHugeMethods flag is a measured interim option, but this issue is to determine whether a source-level split can get the same or better result without changing HotSpot's huge-method policy for every method in the process.

Acceptance

  • HotSpot diagnostics on supported Java versions show the refactored hot interpreter path gets C2 compilation with default JVM flags.
  • Standard Perl behavior and project-owned tests cover affected opcode families; JVM and interpreter backends remain compatible.
  • Run the repository make gate on the immutable candidate.
  • Compare default-flag performance against the exact parent using randomized paired eval STRING benchmark runs with operation counts/checksums; retain the split only when the paired interval shows a real improvement.
  • Check representative non-eval workloads and startup/compilation cost so a faster eval benchmark does not hide a material regression elsewhere.

Related

主要言語
Perl
スター
67
フォーク
8
平均マージ
5時間 12分
マージ済み PR(30日)
131

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

fglock/PerlOnJava のほかの issue

fglock/PerlOnJava の issue をすべて見る

似ている issue

Perl の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。