feat: juliac --trim compatibility#43
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
b47fbfa to
3c7bc7d
Compare
Contributor
Benchmark Results (Julia v1)Time benchmarks
Memory benchmarks
|
fb5230f to
e04e56d
Compare
Make the "open + inspect metadata" workload build cleanly under
`juliac --trim=safe`:
- Annotate every record-parsing function's record-size argument as
`::Type{T} where T`. Julia does not specialize on bare/`::Type` value
args (Type/Function/Vararg heuristic), so they were boxed as abstract
`Type`, making every `sizeof`/`read_be` a dynamic call the trim verifier
rejects.
- Move file-level compression from the `CDFDataset{CT,FST}` type parameter
to a plain field. It is metadata only (the buffer is already decompressed)
and nothing dispatches on it; as a type param the version×compression
product was a 6-way union exceeding the split limit, forcing everything
through abstract `CDFDataset`.
- Replace `open(f, name, mode) do` (varargs splat via `_apply_iterate`,
trim-hostile) with explicit open + try/finally.
- Reorder `getproperty` so real field accesses short-circuit before the lazy
`attrib`/`adr` branches, so a trim build that never reads attributes does
not drag in the heterogeneous attribute machinery.
- Branch on the version literal so the record-size type reaches the loader as
a concrete type parameter rather than a widened `Type` ternary.
Behavior-preserving: Aqua, JET, and the existing suite pass.
Add test/trim.jl (HTTP.jl/SciML-style): locate juliac, develop the package
into a temp project, build a `--trim=safe` probe, run it. Skips when juliac
is unavailable. Variable *data* reading stays out of scope — eltype, ndims
and VDR type are read from the file at runtime and cannot be statically
resolved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes the open + inspect metadata workload build cleanly under
juliac --trim=safe, and adds a regression test for it.What & why
A
--trim=safebuild ofCDFDataset(file)+ metadata access (version,majority,compression,keys) previously failed the trim verifier with 34 errors. Root causes and fixes:Int32/Int64) as a bare/::Typeargument. Julia does not specialize onType/Function/Varargvalue args, so it was boxed as abstractType, making everysizeof/read_bea dynamic call. Now annotated::Type{T} where Tto force specialization.CDFDataset{CT,FST}encoded file-level compression as a type param, but it is metadata only (the buffer is already decompressed) and nothing dispatches on it. The version×compression product was a 6-way union that exceeds Julia's split limit (4), forcing everything through abstractCDFDataset. Moved to a plain field → 2-way concrete union.open(f, name, mode) doblock. Routes through varargs splatting (_apply_iterate) that trim cannot resolve. Replaced with explicit open +try/finally(mmap stays valid after the fd closes, same as before).getpropertylazy branches. Field accesses fell through to the:attrib/:adrbranches beforegetfield, and the optimizer failed to DCE the dead attribute invoke — dragging the heterogeneous attribute machinery (Dict{String,Vector}, runtimejulia_type) into builds that never read attributes. Reordered so fields short-circuit first.Scope
Only the metadata path is trimmable. Variable data reading is inherently dynamic — element type, ndims, and VDR type are read from the file at runtime, so they cannot be statically resolved — and is intentionally out of scope.