Skip to content

staticdata: the system image holds nothing, the boxed integers and its symbols - #63068

Open
levy wants to merge 2 commits into
JuliaLang:masterfrom
levy:pr-image-primordials
Open

staticdata: the system image holds nothing, the boxed integers and its symbols#63068
levy wants to merge 2 commits into
JuliaLang:masterfrom
levy:pr-image-primordials

Conversation

@levy

@levy levy commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

A package image references nothing, the small boxed integers and every symbol by tag, and the loader resolves the tag to an object of the loading runtime. The system image is that runtime, so paying the same way costs it 1.1 million relocations at every start, plus the interning of the whole symbol list. This serializes them as objects instead.

  • nothing: the loader already reads jl_nothing from the image. julia_init allocates one earlier, so the fields of the root task that still point at that one are updated after the relocations, by a walk over the task layout.
  • Boxed integers: two boxes of one value are equal by value, so nothing to adopt.
  • Symbols: serialized with their two tree children. The image records the root, and the loader installs the image's tree as the process symbol table after the relocations. jl_init_common_symbols moves after the restore, and jl_set_root_symbol refuses a non-empty table.

A trimmed image (--trim) keeps the tag encoding: the symbol table is about 2.6 MB, more than a whole trimmed binary. test/trim and the JuliaC tests pass; the trimmed hello world is 1.66 MB and starts in 3.3 ms. Pruning the table to the referenced symbols would be the better answer; it is not in this PR.

julia --startup-file=no -e '', minimum of 15 pinned runs, on top of #63067: 66.2 → 61.4 ms. sys.so grows 2.3 MB.

Test: test/cmdlineargs.jl checks with jl_object_in_image that a started process finds nothing, the booleans, an image symbol, a freshly interned symbol and the nothing fields of the root task in the image, and that a random new symbol is not. core, channels, precompile, syntax and meta pass.

Part of #63065. #63069 needs it to keep the residual list short.

Disclosure: developed with Claude Code (Opus 5) under my direction. It wrote the code and this text; the measurements were run on my machine. I reviewed the changes. The commits carry an Assisted-by trailer.

levy added 2 commits September 8, 2026 18:40
A package image references them by tag, since they belong to the loading
runtime. The system image is that runtime, so it serializes them as objects,
and a field that points at one needs no relocation.

`jl_nothing` is already read from the image as a constant global. `julia_init`
allocates one before the root task exists, so the root task's fields that hold
that one are updated after the relocations, by a walk over the task layout.
Boxed integers need no adoption: two boxes of one value are equal by value.

A trimmed image keeps the tag encoding, to stay small.

Assisted-by: Claude Code (Opus 5)
A package image references a symbol by its index in a name list, and the
loader interns the list. The system image did the same, so every start
interned tens of thousands of names and wrote one pointer per reference.

The system image now serializes its symbols as objects, with their two tree
children, and records the root. The loader installs that tree as the symbol
table of the process after the relocations; a symbol interned later goes into
the same tree. `jl_init_common_symbols` runs after the restore, and
`jl_set_root_symbol` refuses a non-empty table. A trimmed image keeps the
name list, to stay small.

`julia --startup-file=no -e ''`: 66.8 → 61.4 ms, minimum of 15 pinned runs,
on top of the lowering-context change. `sys.so` grows 2.3 MB.

`test/cmdlineargs.jl` checks that a started process finds `nothing`, the
booleans, an image symbol, a freshly interned symbol and the root task's
`nothing` fields in the image, and that a new random symbol is not.

Assisted-by: Claude Code (Opus 5)
@levy
levy force-pushed the pr-image-primordials branch from 81598dd to b8b54f2 Compare September 8, 2026 16:42
@KristofferC

Copy link
Copy Markdown
Member

These PR titles don't really make any sense to me. "the system image holds nothing". Wat? Holds?

@levy

levy commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

These PR titles don't really make any sense to me. "the system image holds nothing". Wat? Holds?

nothing as the value in Julia, not nothing as nothing in English

I'm sorry for the confusing title, it really is confusing.

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.

2 participants