Skip to content

[GR-82350] Adopt execution bytecode serialization. - #1420

Merged
graalvmbot merged 3 commits into
masterfrom
mdsouza/GR-82350-execution-bytecode-serialization
Dec 4, 2026
Merged

graalvmbot merged 3 commits into
masterfrom
mdsouza/GR-82350-execution-bytecode-serialization

Conversation

@graalvmbot

Copy link
Copy Markdown
Collaborator

This change adopts execution bytecode serialization, which allows to directly load bytecode instead of reconstructing it from builder bytecodes.

It also adds a micro-optimization for writes: instead of writing out the little-endian representation of numbers, one byte at a time, uses out.writeInt(Integer.reverseBytes(n)) (and similar) to avoid loops and repeated bounds checks. (writeInt always emits big-endian encoding, so reversing the bytes ensures we always emit little-endian encoding.)

Benchmarking results

Using the code loading workload in GR-82050 (JIT/interpreter is runtime compilation on/off).

The execution bytecodes significantly improve load time at the cost of dump time and byte size:

   medians, in µs/op (unless otherwise specified)

   Operation           CPython 3.14.3    Baseline JIT    Baseline interpreter    Execution JIT    Execution interpreter
  ━━━━━━━━━━━━━━━━━━  ━━━━━━━━━━━━━━━━  ━━━━━━━━━━━━━━  ━━━━━━━━━━━━━━━━━━━━━━  ━━━━━━━━━━━━━━━  ━━━━━━━━━━━━━━━━━━━━━━━
   marshal.loads                 27.1           122.8                   332.6             62.4                    124.0
  ──────────────────  ────────────────  ──────────────  ──────────────────────  ───────────────  ───────────────────────
   First exec                    25.6           329.6                   853.2            115.8                    154.0
  ──────────────────  ────────────────  ──────────────  ──────────────────────  ───────────────  ───────────────────────
   Repeat exec                   31.5            53.9                    55.6             49.1                     56.2
  ──────────────────  ────────────────  ──────────────  ──────────────────────  ───────────────  ───────────────────────
   marshal.dumps                 22.1         1,429.5                 1,331.8          2,202.8                  2,182.8
  ──────────────────  ────────────────  ──────────────  ──────────────────────  ───────────────  ───────────────────────
   Marshalled bytes            16,626         122,090                 122,090          184,240                  184,240

  Loads improve 1.97× JIT / 2.68× interpreter; first execution improves 2.85× / 5.54×. The tradeoff is 54–64% slower serialization and 51% larger payloads.

Adding the write micro-optimization helps a little bit with the dump time (builtin-calls just defines functions, calls invokes them):

  marshal.dumps medians, µs/op:

   Workload              Mode            Before      After    Reduction
  ━━━━━━━━━━━━━━━━━━━━  ━━━━━━━━━━━━━  ━━━━━━━━━  ━━━━━━━━━  ━━━━━━━━━━━
   defs+calls            JIT            2,007.6    1,690.0        15.8%
  ────────────────────  ─────────────  ─────────  ─────────  ───────────
   defs+calls            Interpreter    2,029.5    1,699.8        16.2%
  ────────────────────  ─────────────  ─────────  ─────────  ───────────
   defs+builtin-calls    JIT              945.2      746.1        21.1%
  ────────────────────  ─────────────  ─────────  ─────────  ───────────
   defs+builtin-calls    Interpreter      935.4      804.4        14.0%

@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Dec 4, 2026
@graalvmbot
graalvmbot merged commit e8c1f0a into master Dec 4, 2026
33 of 36 checks passed
@graalvmbot
graalvmbot deleted the mdsouza/GR-82350-execution-bytecode-serialization branch December 4, 2026 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants