It is sometimes the case that a call to an external C library can take a long time; solvers are a good example. We've observed such a call taking tens of minutes, and while that was happening, another Julia thread triggered GC. At this point, all threads stop, except for the thread running the solver call and the program froze until the ccall returned, many minutes later.
If you know that the call to the external library does not manipulate Julia memory, then you can ccalljl_gc_safe_enter and jl_gc_safe_leave before and after the external call.
So:
Is there another solution to this problem?
If not, why is this solution not defined in Base.GC (like GC.safepoint) and documented?
Does it make sense to add a parameter to ccall that allows for it to be a GC safe region automatically?
It is sometimes the case that a call to an external C library can take a long time; solvers are a good example. We've observed such a call taking tens of minutes, and while that was happening, another Julia thread triggered GC. At this point, all threads stop, except for the thread running the solver call and the program froze until the
ccall
returned, many minutes later.If you know that the call to the external library does not manipulate Julia memory, then you can
ccall
jl_gc_safe_enter
andjl_gc_safe_leave
before and after the external call.So:
Base.GC
(likeGC.safepoint
) and documented?ccall
that allows for it to be a GC safe region automatically?