Skip to content

EdgeQuery.initCovering: Use a single iterator#248

Closed
benguild wants to merge 1 commit intogolang:masterfrom
benguild:closestEdgeQueryTODO
Closed

EdgeQuery.initCovering: Use a single iterator#248
benguild wants to merge 1 commit intogolang:masterfrom
benguild:closestEdgeQueryTODO

Conversation

@benguild
Copy link
Copy Markdown
Contributor

@benguild benguild commented Dec 14, 2025

This also fixes #247, but that should probably be merged first while this is reviewed.

Documented previously as the TODO in the code in both Go and C++. This aims to resolve it. If this is not sufficient, please let me know and I'll take a look. I took a shot at the C++ as well (in a draft PR) to match: google/s2geometry#494

@jmr jmr changed the title Resolving iterator TODO in "initCovering()" of EdgeQuery EdgeQuery.initCovering: Use a single iterator Dec 14, 2025
@jmr jmr requested a review from rsned December 14, 2025 10:25
@jmr
Copy link
Copy Markdown
Collaborator

jmr commented Dec 14, 2025

Is it faster? It looks more complicated.

@benguild benguild force-pushed the closestEdgeQueryTODO branch from 9f19ca5 to c8565f7 Compare December 14, 2025 10:32
@benguild
Copy link
Copy Markdown
Contributor Author

Is it faster? It looks more complicated.

Honestly, probably not that much. It's just avoiding the iterator cloning.

@benguild benguild force-pushed the closestEdgeQueryTODO branch from c8565f7 to e4f59a5 Compare December 26, 2025 08:47
@benguild
Copy link
Copy Markdown
Contributor Author

@rsned If you have a moment, would appreciate eyes/consideration on this. Thanks in advance.

@jmr
Copy link
Copy Markdown
Collaborator

jmr commented Dec 29, 2025

Is it faster? It looks more complicated.

Honestly, probably not that much.

There are benchmarks. Could you run them and report the diffs?

@benguild
Copy link
Copy Markdown
Contributor Author

This seems marginal if not performance neutral from a benchmark perspective, the numbers were just noise like ~0.7% or around 1-2% different at least on my machine. Feel free to verify and judge, and decide based on code clarity and consistency with C++ or whatever might be best.

@benguild
Copy link
Copy Markdown
Contributor Author

Just checking in on this, would be great to consider next steps.

@benguild
Copy link
Copy Markdown
Contributor Author

Since #247 is already merged which fixed the bug, and the TODO resolution results in similarly performant (or slightly slower) code, it may be better to remove the TODO instead unless there's a higher level plan here that I'm not aware of. Note that we have draft mirrored on C++ google/s2geometry#494

@panmari
Copy link
Copy Markdown
Collaborator

panmari commented Mar 26, 2026

This seems marginal if not performance neutral from a benchmark perspective, the numbers were just noise like ~0.7% or around 1-2% different at least on my machine. Feel free to verify and judge, and decide based on code clarity and consistency with C++ or whatever might be best.

For completness sake, could you still post the benchmark results? E.g. using https://pkg.go.dev/golang.org/x/tools/cmd/benchcmp, which helps greatly compiling an overview of multiple benchmark runs.

@benguild
Copy link
Copy Markdown
Contributor Author

This seems marginal if not performance neutral from a benchmark perspective, the numbers were just noise like ~0.7% or around 1-2% different at least on my machine. Feel free to verify and judge, and decide based on code clarity and consistency with C++ or whatever might be best.

For completness sake, could you still post the benchmark results? E.g. using https://pkg.go.dev/golang.org/x/tools/cmd/benchcmp, which helps greatly compiling an overview of multiple benchmark runs.

I don't think I wrote one, it's just the one that was pre-existing. (I don't have this code checked out at the moment but if you do and can check out the branch you could run it)

@benguild
Copy link
Copy Markdown
Contributor Author

benguild commented Apr 1, 2026

At this point, I think it's perhaps best to close this with the suggestion the TODO be reconsidered. It's an interesting refactor but it's not clear if the benefits are there. The C++ sibling PR is a draft anyway, and for this to remain in sync it'd need attention on both sides depending on what's best.

@benguild benguild closed this Apr 1, 2026
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.

3 participants