← Back to Pull requests

Split images: write the heap image to the .ji #61649

Closed
unknown closed this pull request without merging on Aug 06, 2026 16:15 UTC
View on GitHub
unknown unknown commented on Apr 24, 2026 20:41 UTC
Author

We've long emitted "split images", meaning a system image using both --output-o and --output-ji when precompiling packages. We do this because we need to be able to look at the .ji header to determine compatibility without dlopen()ing the corresponding .so. The situation looks something like this:

foo.so:
  native dynamic library headers
  .rodata  (allocated, shared)
  .text    (allocated, shared)
  .(l)data (allocated, not shared)
    some variables used by native code
    jl_system_image_data
  .debug_* (not allocated, shared)

foo.ji:
  .ji header
    Julia version info
  cache flags
  syntax version
  worklist
  dependency list
  preferences
  module dependency list
  srctext

"allocated" means it is actually loaded into the process address space, while "shared" sections can be shared between many processes, saving some memory. jl_system_image_data is not directly used by the native code, because we have to fix up all references to it when loading the image. It's nice to have the ability to create a system image in a single file, but there are many downsides to putting the heap image in the dynamic library:

  • It can't be shared, since it's read-write, and we're likely to foil any CoW cleverness the operating system does by touching every single page when we perform the relocations.

  • Huge dynamic libraries are not supported on Windows (we're limited to 4GiB), and this becomes a real problem with PackageCompiler.

  • Large dynamic libraries also clog up the code signing stuff macOS and Windows do now, making everything take longer.

  • In order to get the heap image into the library, we rely on using LLVM to emit an object file containing nothing but the heap image. When the heap is very large, this makes our peak memory use 3x the size of the heap: the original copy, the serialized heap image, and the LLVM ConstantDataArray for the serialized heap image. We try our best to free the useless copy as we go, but we can't avoid creating the 3 copies during this process.
  • This commit attempts to make the situation better, by moving the heap image from the dynamic library to the .ji when using --output-o in conjunction with --output-ji. This has few downsides, since we are already splitting the image across two files:

    foo.so:
      native dynamic library headers
      .rodata  (allocated, shared)
      .text    (allocated, shared)
      .(l)data (allocated, not shared)
        some variables used by native code
      .debug_* (not allocated, shared)
    
    foo.ji:
      .ji header
        Julia version info
      cache flags
      syntax version
      worklist
      dependency list
      preferences
      module dependency list
      heap image (optionally compressed)
      srctext
    

    In addition, this change adds support for compiling split system images (in addition to the already-supported split pkgimages). To use a split system image, you provide the .so to the -J argument to Julia, and the .so looks for a sibling .ji file to load the heap image from.

    Other than helping support very large heap images on Windows, we also drop the peak memory consumption when compiling such an image by avoiding the third copy for LLVM (see attached plot).

    <img width="1300" height="700" alt="phys_bars" src="https://github.com/user-attachments/assets/52e520c3-aa08-455f-a517-22829fe311da" />

    Diff: 421 lines (+315 / -106) across 5 files Reviewer: xal-0 Review duration: 149494m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 421 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.362
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #61649"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45% (MEDIUM) · Higher = larger blast radius
    45%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.8% · Safe to merge
    17.8%