-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speedup conversion from types <: DataType
or <: UnionAll
to CEnum.Cenum
or Enum
type ids
#262
Comments
That sounds like a proposition to me with almost no downsides, I'm curious what led to your choice of types (compared with e.g. #246)? Is it for the machinery of generated functions? |
Well here is what I did:
The Regarding the case of issue #246, maybe we could make |
While raising this issue, I had not in mind the usage of In those functions, the convert time must be less than 20% of the total time spent in EDIT 1: julia> AG.read("test/data/point.geojson") do ds
AG.getlayer(ds) do layer
AG.getfeature(layer, 0) do f
@code_warntype GDAL.ogr_f_getfieldasstring(f.ptr, 1)
end
end
end
Variables
#self#::Core.Const(GDAL.ogr_f_getfieldasstring)
arg1::Ptr{Nothing}
arg2::Int64
Body::Union{Nothing, String}
1 ─ %1 = Base.cconvert(GDAL.OGRFeatureH, arg1)::Ptr{Nothing}
│ %2 = Base.cconvert(GDAL.Cint, arg2)::Int32
│ %3 = Base.unsafe_convert(GDAL.OGRFeatureH, %1)::Ptr{Nothing}
│ %4 = Base.unsafe_convert(GDAL.Cint, %2)::Int32
│ %5 = $(Expr(:foreigncall, :(Core.tuple(:OGR_F_GetFieldAsString, GDAL.libgdal)), Cstring, svec(Ptr{Nothing}, Int32), 0, :(:ccall), :(%3), :(%4), :(%2), :(%1)))::Cstring
│ %6 = GDAL.aftercare(%5, false)::Union{Nothing, String}
└── return %6
julia> AG.read("test/data/point.geojson") do ds
AG.getlayer(ds) do layer
AG.getfeature(layer, 0) do f
@code_warntype AG.asstring(f, 1)
end
end
end
Variables
#self#::Core.Const(ArchGDAL.asstring)
feature::ArchGDAL.Feature
i::Int64
Body::String
1 ─ %1 = ArchGDAL.String::Core.Const(String)
│ %2 = GDAL.ogr_f_getfieldasstring::Core.Const(GDAL.ogr_f_getfieldasstring)
│ %3 = Base.getproperty(feature, :ptr)::Ptr{Nothing}
│ %4 = (%2)(%3, i)::Union{Nothing, String}
│ %5 = Base.convert(%1, %4)::String
│ %6 = Core.typeassert(%5, %1)::String
└── return %6 EDIT 2: (eval(T2) isa Type{DataType}) && (eval(T1) <: OGRFieldType) || push!( to drop the Running ArchGDAL.jl/test/test_convert.jl Lines 64 to 65 in 17b7e7d
ArchGDAL.jl/test/test_types.jl Line 24 in 17b7e7d
ArchGDAL.jl/test/test_types.jl Line 29 in 17b7e7d
So these conversion functions may be useless. The move of the dictionary lookup from runtime to compile time might be useful for some other conversions, but I propose to tackle the issue #246 first |
OGRFieldType
and OGRFieldSubType
to DataType
<: DataType
or <: UnionAll
to CEnum.Cenum
or Enum
type ids
So sorry for my late response, I was dealing with a lot recently. I have not started working on #246 and have assigned it to you instead, thank you! |
@yeesian and @visr, I may have found a way to speedup conversion from
OGRFieldType
andOGRFieldSubType
toDataType
x200 times.This could notably speedup layer to table conversions.
In order to move the
Dict
lookup from runtime to compile time, we can create a realOGRFieldType
instead of using directly a type id as we do currently,OGRFieldType
being anEnum
This would allow to use generated convert functions and simplify
@convert
macro by the wayI have added the following code mockup to types.jl:
nothing
could be replaced to throw error when lookup failsThis gives:
The text was updated successfully, but these errors were encountered: