PkgCacheInspector
Documentation for PkgCacheInspector.
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.PkgCacheInfoPkgCacheInspector.PkgCacheSizesPkgCacheInspector.extending_external_methodsPkgCacheInspector.info_cachefile
PkgCacheInspector.info_cachefile — Function
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) → cfReturn 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.
PkgCacheInspector.PkgCacheInfo — Type
struct PkgCacheInfoObjects 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 viajl_method_table_activate(the underlyingTypeMapEntrys live inextext_entries). On modern Julia with a single globaljl_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. Useextending_external_methodsto 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_methodsto the inspector svec), this list is always empty: the underlyingTypeMapEntryarray 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):Baseowns 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 (anexternal_targetslookup table) no longer reflect whatjl_restore_incrementalreturns.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 incachesizes.cachesizes: Sizes of the individual sections. SeePkgCacheSizes.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 theMethodobjects whoseprimary_worldfield is bumped byjl_activate_methods; on the current single-global-jl_method_tabledesign they are the sameMethods thatexternal_methodswraps inTypeMapEntrys, just enumerated as bareMethodobjects for a different load-time purpose. Empty on Julia 1.12 where the loader does not surface this list; in that casecount_internal_methodsfalls back to walking the global method table.verbose: Verbose output mode for displaying method information.
PkgCacheInspector.PkgCacheSizes — Type
struct PkgCacheSizesStores 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 byinfo_cachefile.isbitsdata: Size of theconstinternal 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.
PkgCacheInspector.extending_external_methods — Function
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.