-
Notifications
You must be signed in to change notification settings - Fork 2
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
Efficient coordinate collection from LineString
s using reinterpret
#32
Comments
Fun thing, doing the above works fine, but ofcourse changes the return type to an NTuple. That sorta implies we got to change the return types of the other (point) methods too, which actually could slow down things: function GI.getcoord(::GI.PointTrait, geom::WKBtype)
offset = 1
ncoord = GI.ncoord(geom)
data = @view geom.val[headersize+offset:headersize+offset+sizeof(Float64)*ncoord-1]
reinterpret(Float64, data) # current 211.961 ns (2 allocations: 112 bytes)
only(reinterpret(NTuple{ncoord,Float64}, data)) # 580.569 ns (7 allocations: 320 bytes)
GC.@preserve geom unsafe_load(Ptr{NTuple{ncoord,Float64}}(pointer(geom.val, headersize + offset))) # 466.837 ns (6 allocations: 224 bytes)
end |
Have you profiled this? That just looks like type instability to me |
Those three different variants were run using btime yes. |
No I mean ProfileView... Yours will have some red |
With the linked PR import GeoFormatTypes as GFT, WellKnownGeometry as WKG, GeoInterface as GI
tups = tuple.(rand(300_000), rand(300_000))
geoms_as_linestring = WKG.getwkb(GI.LineString(tups))
@btime GI.coordinates(geoms_as_linestring);
98.625 μs (5 allocations: 4.58 MiB) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: