Skip to content

Improve WKT performance by writing coordinates directly - #58

Merged
evetion merged 1 commit into
mainfrom
fix/wkt-perf
Jul 31, 2026
Merged

Improve WKT performance by writing coordinates directly#58
evetion merged 1 commit into
mainfrom
fix/wkt-perf

Conversation

@evetion

@evetion evetion commented Jul 31, 2026

Copy link
Copy Markdown
Owner

@asinghvi17 This makes it faster then ArchGDAL again, at the cost of use internal Base methods.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves WKT serialization performance by avoiding generic float printing and writing floating-point coordinates directly into an IOBuffer, and tightens the allocation regression test to reflect the intended improvement.

Changes:

  • Add a specialized write_coordinate fast path using Base.Ryu.writeshortest for IOBuffer + Float* coordinates.
  • Route point-coordinate serialization through write_coordinate instead of print.
  • Lower the WKT allocation ceiling in tests to enforce the performance improvement.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/wkt.jl Introduces a fast-path for writing float coordinates directly into an IOBuffer during WKT generation.
test/runtests.jl Tightens the allocation threshold for getwkt to validate the reduced-allocation behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/wkt.jl
Comment on lines +57 to +64
function write_coordinate(io::IOBuffer, value::Union{Float16,Float32,Float64})
Base.ensureroom(io, 24)
io.ptr = Base.Ryu.writeshortest(io.data, io.ptr, value)
io.size = max(io.size, io.ptr - 1)
return nothing
end

write_coordinate(io::IO, value) = print(io, value)
@evetion
evetion merged commit f4208de into main Jul 31, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants