Skip to content

Module loading slow due to method insertion and external target verification #48092

@topolarity

Description

@topolarity

Now that #47184 is landed (🎉 ), load time has become a significant fraction of TTFX. At @staticfloat's recommendation, I wanted to share some early profiling results.

Command: using CairoMakie
Platform: x86_64-darwin
Total load time: 11.78s

The big contributors to load time appear to be:

  1. jl_verify_edges, 56% (6.54s): These calls are fast, but we are severely strained by their quantity. In total, 180k external targets in CairoMakie and its dependencies trigger 180k calls to jl_matching_methods.
  2. jl_insert_methods, 21% (2.44s): The slowest (>40ms, up to 500ms) calls to insert new methods make the biggest contribution here, accounting for more than 80% of the total call time.

The next major contributor would be jl_restore_package_image_from_stream_at 0.95s (8% of load time), but I haven't instrumented it in detail. Depending on I/O and dyld cache details, I've also measured up to 20% of load time spent in jl_dlopen. I doubt too much can be done to improve that number, and once caches are warm it typically falls to ~1%.

Tracing was done with Tracy. You can examine the trace file locally or in the browser.

To see what was instrumented, take a look at this commit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions