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

union op causes out of bounds error using i_overlay 1.7.4 #1273

Closed
urschrei opened this issue Nov 18, 2024 · 12 comments · Fixed by #1277
Closed

union op causes out of bounds error using i_overlay 1.7.4 #1273

urschrei opened this issue Nov 18, 2024 · 12 comments · Fixed by #1277

Comments

@urschrei
Copy link
Member

Repro:

try to union this geometry (valid WKT AFAIK) using the unary_union branch in #1246.

Result:

---- algorithm::bool_ops::tests::unary_perf stdout ----
thread '<unnamed>' panicked at /Users/sth/.cargo/registry/src/index.crates.io-6f17d22bba15001f/i_overlay-1.7.4/src/bind/solver.rs:64:42:
index out of bounds: the len is 7 but the index is 18446744073709551615
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at /Users/sth/.cargo/registry/src/index.crates.io-6f17d22bba15001f/i_overlay-1.7.4/src/bind/solver.rs:64:42:
index out of bounds: the len is 4 but the index is 18446744073709551615
thread '<unnamed>' panicked at /Users/sth/.cargo/registry/src/index.crates.io-6f17d22bba15001f/i_overlay-1.7.4/src/bind/solver.rs:64:42:
index out of bounds: the len is 13 but the index is 18446744073709551615
thread '<unnamed>' panicked at /Users/sth/.cargo/registry/src/index.crates.io-6f17d22bba15001f/i_overlay-1.7.4/src/bind/solver.rs:64:42:
index out of bounds: the len is 42 but the index is 18446744073709551615
thread '<unnamed>' panicked at /Users/sth/.cargo/registry/src/index.crates.io-6f17d22bba15001f/i_overlay-1.7.4/src/bind/solver.rs:64:42:
index out of bounds: the len is 42 but the index is 18446744073709551615

Note the i_overlay version. Unfortunately there's no way to use 1.7.2 using our current Cargo.toml. This works:

-i_overlay = { version = "1.7.2, < 1.8.0", default-features = false }
+i_overlay = { version = "=1.7.2", default-features = false }
@urschrei
Copy link
Member Author

(Test was run in release mode, fyi)

@kirillolenev-dm
Copy link

The same issue I got. geo 0.29.2. Any workaround so far?

@frewsxcv
Copy link
Member

Should we pin to 1.7.2? And has this been reported upstream to i_overlay?

@urschrei
Copy link
Member Author

urschrei commented Nov 24, 2024

I think we should pin, yes. We can't report yet because there have now been subsequent i_overlay releases which may have fixed the issue, but we can't test against them because of broken API compat.

So I think we need to do the following:

  1. Pin to 1.72, which will unbreak geo
  2. Rewrite our i_overlay compatibility module for the post 1.72 API
  3. Write a (possibly breaking) test against the current i_overlay version and report that if necessary

Bonus:
establish a strategy which prevents geo and downstream consumers from being vulnerable to i_overlay breaking semver compat, while allowing us to keep abreast of released improvements, as there's a lot going on at the moment (better solver, multithreading etc) and we definitely want those changes. That may be as simple as pinning a version and maintaining an i_overlay_improvements branch for experimentation – haven't thought about it too much.

@michaelkirk
Copy link
Member

michaelkirk commented Nov 25, 2024 via email

@michaelkirk
Copy link
Member

Can you zip and upload the wkt here? I don't have a dropbox account.

@michaelkirk
Copy link
Member

Can you see if #1275 (i_overlay 1.8) fixes anything for you @urschrei ?

Or i_overaly 1.9: https://github.com/georust/geo/tree/mkirk/i_overlay_1.9

@urschrei
Copy link
Member Author

urschrei commented Nov 26, 2024

Tests now pass on #1275, with a slight perf improvement over 1.72, but note that the results are different (we end up with fewer output points – I think this is good?)

Multi-Threaded Unary Union Perf Test

2.42s -> 2.05s
Using 1.9, perf improves a little more over #1275: 2.05s -> 1.85s

Note that this isn't a criterion-based test as that isn't feasible given the duration, but considering how much work is being done, the timings are stable.

@urschrei
Copy link
Member Author

Uhhh possibly may have spoken too soon: results for the same test (number of output polygon points) varies between single- and multi-threaded versions of the algorithm.

multi-thread: 3539
single-thread: 3541

It's a small difference, but I'm not sure why it's arising. Let me check whether it's the same on 1.72…

@urschrei
Copy link
Member Author

(I will also note that single-thread perf for that test using 1.9 is 11.3s -> 6.1s. That's a very big improvement…)

@urschrei
Copy link
Member Author

Also seeing differences (different differences ofc) between single- and multi on 1.72, so that's something to dig into separately as part of #1246.

michaelkirk added a commit that referenced this issue Nov 26, 2024
Note there is a serious performance regression for larger geometries in our benchmarks vs. 1.8.

    cargo bench --bench=boolean_ops -- --baseline=main
    ... small ones are fine, but big ones have huge regression
    Circular polygon boolean-ops/bops::union/1024
                            time:   [4.3625 ms 4.3922 ms 4.4093 ms]
                            change: [+1.7493% +2.4971% +3.2026%] (p = 0.00 < 0.05)
                            Performance has regressed.
    Circular polygon boolean-ops/bops::intersection/2048
                            time:   [14.057 ms 14.115 ms 14.157 ms]
                            change: [+9.0224% +10.438% +11.658%] (p = 0.00 < 0.05)
                            Performance has regressed.
    Circular polygon boolean-ops/bops::union/2048
                            time:   [14.012 ms 14.071 ms 14.134 ms]
                            change: [+11.212% +12.141% +13.317%] (p = 0.00 < 0.05)
                            Performance has regressed.
    Found 1 outliers among 10 measurements (10.00%)
      1 (10.00%) high severe
    Circular polygon boolean-ops/bops::intersection/4096
                            time:   [360.66 ms 361.18 ms 361.83 ms]
                            change: [+709.38% +713.12% +716.34%] (p = 0.00 < 0.05)
                            Performance has regressed.
    Found 2 outliers among 10 measurements (20.00%)
      2 (20.00%) high severe
    Circular polygon boolean-ops/bops::union/4096
                            time:   [361.35 ms 361.71 ms 362.13 ms]
                            change: [+710.58% +713.76% +716.59%] (p = 0.00 < 0.05)
                            Performance has regressed.

Likely this is because there is a new heuristic for "solver" strategies
based on how big your input is - the cliff likely indicates the switch
to one of the solvers used for larger inputs.

See iShape-Rust/iOverlay#13

There are significant gains with some "real world" data, e.g. urshrei's cascaded
union tests:
#1273 (comment)

I'm more inclined to trust that more realistic data over the synthetic
geometries we use in our benchmarks.

Plus, I'd prefer to leave in performance twiddling to upstream and
contribute changes there rather than fine-tuning things at our own
call sites.
@urschrei
Copy link
Member Author

urschrei commented Dec 1, 2024

Closed by #1275

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants