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

UndefVarError from getfield(Main, Symbol("##xx#xx")) symbols not defined #26

Closed
baggepinnen opened this issue May 11, 2019 · 1 comment

Comments

@baggepinnen
Copy link

baggepinnen commented May 11, 2019

(On julia v1.2) I'm trying snoopcompile out for the first time. When snooping while running the tests of my package, the generated precompile file contains a lot of code with getfield(Main, Symbol("##xx#xx")), like this

precompile(Tuple{typeof(MonteCarloMeasurements.gradient), getfield(Main, Symbol("##28#95")), MonteCarloMeasurements.Particles{Float64, 500}})

which causes

julia> using MonteCarloMeasurements
[ Info: Recompiling stale cache file /local/home/fredrikb/.julia/compiled/v1.2/MonteCarloMeasurements/tHYBD.ji for MonteCarloMeasurements [0987c9cc-fe09-11e8-30f0-b96dd679fdca]
ERROR: Error while loading expression starting at /local/home/fredrikb/.julia/dev/MonteCarloMeasurements/src/MonteCarloMeasurements.jl:89
caused by [exception 1]
UndefVarError: ##28#95 not defined
Stacktrace:
 [1] _precompile_() at /local/home/fredrikb/.julia/dev/MonteCarloMeasurements/src/precompile_MonteCarloMeasurements.jl:11

I guess that the line in runtests.jl that lead to this is somewhere here
Am I doing something wrong?

For reference, the code used to generate the precompile file is below

using SnoopCompile
SnoopCompile.@snoopc "/tmp/robust_opt_compiles.log" begin
    using MonteCarloMeasurements, Pkg
    include(joinpath(dirname(dirname(pathof(MonteCarloMeasurements))), "test", "runtests.jl"))
end
data = SnoopCompile.read("/tmp/robust_opt_compiles.log")
pc = SnoopCompile.parcel(reverse!(data[2]))
SnoopCompile.write("/tmp/precompile", pc)
@baggepinnen baggepinnen changed the title UndefVarError from ##xx##xx symbols not defined UndefVarError from getfield(Main, Symbol("##xx#xx")) symbols not defined May 11, 2019
@timholy
Copy link
Owner

timholy commented May 16, 2019

When I first wrote this package, I didn't realize that precompilation only saves inference time. So the @snoopc mechanism, while seemingly more sophisticated, is prioritizing the wrong stuff. If you're on Julia 1.2, I highly recommend @snoopi. Personally, I then write the corresponding precompile statements manually. Note that because of the issue diagnosed in JuliaLang/julia#31466 (which is also partway towards a fix), many things fail to precompile (unfortunately).

But I will try to fix this. Those ##28##95 objects correspond to anonymous functions, and the numbering is not consistent from session to session.

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

No branches or pull requests

2 participants