Skip to content
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

DistanceOp: Add short-circuit for point-point distance #1067

Merged
merged 1 commit into from
Apr 15, 2024

Conversation

dbaston
Copy link
Member

@dbaston dbaston commented Apr 15, 2024

Relates to #1066

Add a short circuit to reduce point-point computation time by ~90%.

@dr-jts
Copy link
Contributor

dr-jts commented Apr 15, 2024

Good find, @dbaston . Can you add the benchmark output to this PR for ease of seeing it?

@dr-jts
Copy link
Contributor

dr-jts commented Apr 15, 2024

I guess there could be some other optimizations added as well, such as Point-Linestring, or perhaps LineString-LineString? But maybe the returns diminish very quickly.

@dr-jts dr-jts added the Enhancement New feature or feature improvement. label Apr 15, 2024
@dbaston
Copy link
Member Author

dbaston commented Apr 15, 2024

It looks like there is opportunity for more improvements to the general case. For example, in the point-point case we are spending ~50% of the total time in PolygonExtracter and PointExtracter (without this short-circuit):

image

@dr-jts
Copy link
Contributor

dr-jts commented Apr 15, 2024

It looks like there is opportunity for more improvements to the general case. For example, in the point-point case we are spending ~50% of the total time in PolygonExtracter and PointExtracter (without this short-circuit):

Yes, perhaps some checking of dimensions could avoid calling the extracters if there is nothing for them to extract.

@dbaston dbaston merged commit ba59b3f into libgeos:main Apr 15, 2024
30 checks passed
@dbaston
Copy link
Member Author

dbaston commented Apr 15, 2024

Can you add the benchmark output to this PR for ease of seeing it?

main:

Running bin/perf_distance
Run on (8 X 4200 MHz CPU s)
CPU Caches:
  L1 Data 32 KiB (x4)
  L1 Instruction 32 KiB (x4)
  L2 Unified 256 KiB (x4)
  L3 Unified 6144 KiB (x1)
Load Average: 0.66, 0.69, 0.83
***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead.
----------------------------------------------------------------
Benchmark                      Time             CPU   Iterations
----------------------------------------------------------------
BM_PointPointDistance   23094470 ns     23093762 ns           31

this PR:

2024-04-15T14:46:45-04:00
Running bin/perf_distance
Run on (8 X 4200 MHz CPU s)
CPU Caches:
  L1 Data 32 KiB (x4)
  L1 Instruction 32 KiB (x4)
  L2 Unified 256 KiB (x4)
  L3 Unified 6144 KiB (x1)
Load Average: 0.55, 0.67, 0.82
***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead.
----------------------------------------------------------------
Benchmark                      Time             CPU   Iterations
----------------------------------------------------------------
BM_PointPointDistance    2136982 ns      2136823 ns          328

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or feature improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants