(misintepreted and not exist) Overhead in ccall due to unsafe_convert of pointers

I strongly suspect that you’re not measuring what you think you’re measuring. For example, the “allocation” you’re seeing in your benchmark for unsafe_convert is very likely due to a being an untyped, non-const global variable, and not due to unsafe_convert. In particular, consider the first two performance tips from the docs.

Also, there is no need for using Core.apply_type here. You can just write Ptr{Cdouble}. See also the @ccall docs for how to use ccall.

Could you show a representative MWE of your actual benchmark for the 130s that we can replicate on our end?

1 Like