How to debug compiler hang?

I’ve got a piece of long-running code which runs for about 5min, then, on what seems like a totally benign command, hangs for like 10minutes, every time. It does eventually complete and continue running after that. I think its doing inference / compilation, but I’m not entirely sure. How do I go about debugging something like this?

The place it hangs is something like:

@show Dates.now()
map(arr) do x
    @show Dates.now()
    ...
end

and there’s 10min between the two now()s shown. My guess is what’s happening there is compiling/infering the function thats getting mapped, and there’s something in there it doesn’t like?

This is a huge code base and given that it takes 5min just to get to the part where it hangs, it seems like it would take forever to slowly strip away stuff until I get to a MWE, unless I have a better idea of what the offending code might look like. The code is a CUDA+Zygote kind of thing, if that offers any hints. Thanks for any ideas.