PkgCacheInspector

Documentation for PkgCacheInspector.

Tip

See the README for a usage demo.

This documentation provides reference information which may be useful for understanding more about the information returned by info_cachefile.

PkgCacheInspector.info_cachefileFunction
info_cachefile(pkgname::AbstractString; verbose::Symbol=:none) → cf
info_cachefile(pkgid::Base.PkgId; verbose::Symbol=:none) → cf
info_cachefile(pkgid::Base.PkgId, ji_cachefilename; verbose::Symbol=:none) → cf

Return a snapshot cf of a package cache file. Displaying cf prints a summary of the contents, but the fields of cf can be inspected to get further information (see PkgCacheInfo).

The verbose parameter controls the level of detail in the output:

  • :none (default): Show summary information only

  • :internal: Show detailed information about internal methods

  • :external: Show detailed information about external methods and specializations

  • :all: Show detailed information about both internal and external methods

After calling info_cachefile("MyPkg") you can also execute using MyPkg to make the image loaded by info_cachefile available for use. This can allow you to load cfs for multiple packages into the same session for deeper analysis.

Warning

Your session may be corrupted if you run info_cachefile for a package that had already been loaded into your session. Restarting with a clean session and using info_cachefile before otherwise loading the package is recommended.

source
PkgCacheInspector.PkgCacheInfoType
struct PkgCacheInfo

Objects stored the pkgimage. The main contents are the modules themselves, but some additional objects are stored external to the modules. It also contains the data used to perform invalidation-checks.

  • cachefile: The filename of the cache.

  • modules: The list of modules stored in the package image. The final one is the "top" package module.

  • init_order: The list of modules with an __init__ function, in the order in which they should be called.

  • external_methods: Every method defined by this pkgimage that must be re-installed into the global method table at load time via jl_method_table_activate (the underlying TypeMapEntrys live in extext_entries). On modern Julia with a single global jl_method_table, this includes all worklist-defined methods, not only methods extending externally-owned functions — the historic "extext" / "external" name predates the single-global-mt design. Use extending_external_methods to filter to the true "extending external" subset.

    Note

    On Julia 1.13 through Julia 1.14.0-DEV (prior to the upstream fix that restores extext_methods to the inspector svec), this list is always empty: the underlying TypeMapEntry array is populated by the loader but discarded before it reaches external callers. The information is therefore unavailable to PkgCacheInspector on those releases.

  • internal_method_specializations: The list of method specializations for methods defined within the package's own modules. These are specializations that were added during precompilation but belong to the package's own methods.

  • new_specializations: The list of novel specializations of external methods that were created during package precompilation. E.g., get(::Dict{String,Float16}, ::String, ::Nothing): Base owns the method and all the types in this specialization, but might not have precompiled it until it was needed by a package.

  • new_method_roots: Methods that gained new GC roots during precompilation, paired flat as [method, roots, method, roots, …]. This includes both internal and external methods. These roots are an internal detail of how type-inferred code is compressed for serialization.

  • edges: Reserved for backward compatibility; currently always empty. The previous semantics (an external_targets lookup table) no longer reflect what jl_restore_incremental returns.

  • filesize: The total size of the file that was loaded. For pkgimage loads this is the shared library (.so/.dylib), which also contains native code and object-file overhead, so it exceeds the sum of the serialized-data segment sizes in cachesizes.

  • cachesizes: Sizes of the individual sections. See PkgCacheSizes.

  • image_targets: The image targets that were cloned into the pkgimage, if used.

  • internal_methods: Methods reached by the loader's fixup walk on this pkgimage (Julia ≥ 1.13). These are the Method objects whose primary_world field is bumped by jl_activate_methods; on the current single-global-jl_method_table design they are the same Methods that external_methods wraps in TypeMapEntrys, just enumerated as bare Method objects for a different load-time purpose. Empty on Julia 1.12 where the loader does not surface this list; in that case count_internal_methods falls back to walking the global method table.

  • verbose: Verbose output mode for displaying method information.

source
PkgCacheInspector.PkgCacheSizesType
struct PkgCacheSizes

Stores the sizes of different "sections" of the pkgimage. The main section is the package image itself. However, reconstructing a pkgimage for use requires auxiliary data, like the addresses of internal pointers that need to be modified to account for the actual base address into which the pkgimage was loaded. Each form of auxiliary data gets stored in distinct sections.

  • sysdata: Size of the image. This is the portion of the file that gets returned by info_cachefile.

  • isbitsdata: Size of the const internal data section (storing things not visible from Julia, like datatype layouts).

  • symboldata: Size of the symbol section, for Symbols stored in the image.

  • tagslist: Size of the GC tags section, holding references to objects that require special re-initialization for GC.

  • reloclist: Size of the relocation-list section, holding references to within-image pointers that need to be offset by the actual base pointer upon reloading.

  • gvarlist: Size of the "gvar" (global variable) list of LLVM-encoded objects.

  • fptrlist: Size of the function-pointer list, referencing native code.

source
PkgCacheInspector.extending_external_methodsFunction
extending_external_methods(info::PkgCacheInfo) -> Vector{Method}

Return the subset of info.external_methods whose specialized function is owned by a module outside this pkgimage's worklist — i.e., the true "extending external functions" subset (e.g., a package's Base.show(::IO, ::MyType) method). Ownership is derived from the function type in the method signature.

Constructor signatures and keyword-call wrappers are resolved to their underlying type or function before classifying ownership.

source