Proj.jl icon indicating copy to clipboard operation
Proj.jl copied to clipboard

dynamic dispatch in Proj.proj_trans

Open ctessum opened this issue 2 months ago • 5 comments

Hello,

I'm using Proj in some code where I'm trying to avoid allocations and dynamic dispatches for performance. To assist with this, I'm using the AllocCheck.jl packages, which finds allocations and dynamic dispatches in the code. So this example:

using Proj
using AllocCheck

const pj = Proj.proj_create_crs_to_crs(
    "EPSG:4326",  # source
    "+proj=utm +zone=32 +datum=WGS84",  # target, also EPSG:32632
)
const a = Proj.proj_coord(12, 55)

Proj.proj_trans(pj, Proj.PJ_FWD, a)

@check_allocs checkf(a) = Proj.proj_trans(pj, Proj.PJ_FWD, a)

try
    checkf(a)
catch err
    err.errors
end

gives the following error message:

Dynamic dispatch in ....julia/packages/Proj/YfK57/src/libproj.jl:494
  | @ccall libproj.proj_trans(P::Ptr{PJ}, direction::PJ_DIRECTION, coord::Coord)::Coord

Stacktrace:
 [1] proj_trans
   @ ~/.julia/packages/Proj/YfK57/src/libproj.jl:494 [inlined]
 [2] var"##checkf#260"(a::Coord)
 ....

I don't know enough about @ccall to be able to tell what the issue is, if there is one. Any suggestions would be appreciated!

ctessum avatar Apr 16 '24 01:04 ctessum