In one of my packages I tried to lower import times, so I added a couple of typical usage examples in a “precompile” function. Something like
# my "typical use case" code
ccall(:jl_generating_output, Cint, ()) == 1 || return nothing
# precompile directives from SnoopCompile
However, in the presence of the _my_precompile, benchmarks of my code show thousands of allocations in code that should not be allocating. On the other hand, after I remove _my_precompile, all these spurious allocations disappear, as they should.
I am deeply confused. How can precompilation functions that do not change the code lead to different allocation behavior during use of the library?
I’m bumping this since I am also interested in the answer.
A while ago I have posted a similar question to this:
I think it ultimately has to do with the fact that precompilation needs more than to just call a typical use case function, apparently you also have to explicitly specify input types (?).
At least that was my takeaway so far, hopefully someone who knows more on this can enlighten us here