Skip to content

--trace-compile ignores inferred const-return Methods #58482

@topolarity

Description

@topolarity

If you write a method that ends up being inferred to a Const(...) return value:

julia> const k = rand(1:100)
61
julia> foo() = *(k, 15, 12)
julia> @code_typed foo()
CodeInfo(
1return 10980
) => Int64

it will not be included in the --trace-compile output:

$ julia --trace-compile=stderr -e "const k = rand(1:100); (foo() = *(k, 15)); println(foo())"
precompile(Tuple{typeof(Base.rand), Base.UnitRange{Int64}})
precompile(Tuple{typeof(Base.println), Int64})
precompile(Tuple{typeof(Base.println), Base.TTY, Int64})
705

Even though we ran our compilation pipeline on foo() for the first time (generating a new CodeInstance), it ended up not needing to compile via LLVM so it is excluded from the output.

A user may hope to use the output of --trace-compile to determine whether they should add precompile(foo, ()) to the pre-compilation workload, If we had reported this MethodInstance, it would have saved them that inference time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    latencyLatencyobservabilitymetrics, timing, understandability, reflection, logging, ...

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions