Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit that calls to external methods should be traced back to MyPackage #43

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

serenity4
Copy link

This should help users avoid issues when directly precompiling methods they don't own in their Startup package.

I also changed @snoopi_deep to @snoop_inference and @snoopr to @snoop_invalidations, I think those were leftovers from timholy/SnoopCompile.jl#386.

Copy link
Member

@timholy timholy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is indeed helpful.

!!! warning
If you want to manually precompile methods defined in *other* packages, you must ensure that the corresponding calls are
made in a method belonging to `MyPackage`, otherwise these calls will not be captured during precompilation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not true, and indeed it's the main reason for the existence of PrecompileTools.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am observing this behavior though, which motivated the PR. Perhaps that is a bug?

The case I stumbled upon was with this precompilation workload on a dummy package:

module TestPackage

using Meshes # package for which to precompile methods
using PrecompileTools

function workload()
  geometry = PolyArea((0, 0), (1, 0), (1, 1), (1, 0))
  simplexify(geometry)
end

@compile_workload begin
  workload()
end

end # module

Essentially, with the workload() function indirection, I get correct precompilation:

julia> using TestPackage

julia> using Test

julia> @time @eval TestPackage.simplexify(TestPackage.PolyArea((0, 0), (1, 0), (1, 1), (1, 0)))
  0.002689 seconds (1.39 k allocations: 64.922 KiB, 91.12% compilation time)

While having an "inline" workload as

@compile_workload begin
  geometry = PolyArea((0, 0), (1, 0), (1, 1), (1, 0))
  simplexify(geometry)
end

does not seem to retain compilation results:

julia> @time @eval TestPackage.simplexify(TestPackage.PolyArea((0, 0), (1, 0), (1, 1), (1, 0)))
  4.072428 seconds (40.46 M allocations: 1.983 GiB, 3.30% gc time, 99.99% compilation time)

Should I file an issue about that? If the function indirection should not be necessary, I can remove that doc change and we can merge the other renamings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants