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

Fix/out of bounds while decoding #37

Merged
merged 12 commits into from
Apr 26, 2024

Conversation

mattiZed
Copy link
Contributor

@mattiZed mattiZed commented Apr 24, 2024

This PR is a fix for #36.

I'd like to add that this issue was probably not caught earlier because the "broken_string" test is a bit misleading. While the polyline in that test is "broken" it still decodes fine, the decoded data is just meaningless. It would only trigger "should_panic" because of the test's assertion not holding. I have refactored another test with a similar issue.

I have also added a test with an input that actually causes the out-of-bounds error.

On my machine, there is a performance hit:

     Running benches/benchmarks.rs (target/release/deps/benchmarks-47700460fb2f8668)
bench encode: 1000 coordinates
                        time:   [50.426 µs 50.577 µs 50.744 µs]
                        change: [-11.202% -10.880% -10.555%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 12 outliers among 100 measurements (12.00%)
  9 (9.00%) high mild
  3 (3.00%) high severe

bench decode: 21502 coordinates
                        time:   [231.81 µs 233.17 µs 234.88 µs]
                        change: [+4.7448% +5.2551% +5.7437%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 5 outliers among 100 measurements (5.00%)
  5 (5.00%) high severe

bench polyline6 decoding
                        time:   [40.434 ns 40.524 ns 40.623 ns]
                        change: [+9.1684% +9.8057% +10.405%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 10 outliers among 100 measurements (10.00%)
  4 (4.00%) high mild
  6 (6.00%) high severe

bench HUGE polyline6 decoding
                        time:   [30.727 µs 30.855 µs 31.013 µs]
                        change: [+12.223% +12.654% +13.046%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 4 outliers among 100 measurements (4.00%)
  3 (3.00%) high mild
  1 (1.00%) high severe

I can't tell if this is still acceptable.

@mattiZed mattiZed force-pushed the fix/out-of-bounds-while-decoding branch from 7124ec5 to faedc5e Compare April 24, 2024 16:48
@mattiZed
Copy link
Contributor Author

I have gone back and forth on this a bit (as you can probably tell from the commits) - I'm happy with this version now, the performance hit seems very small.

Copy link
Member

@urschrei urschrei left a comment

Choose a reason for hiding this comment

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

No need to unwrap() here: we return a Result from this function so we can check for Err values and pass them up the chain.

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@urschrei
Copy link
Member

Perf regression on decodes is 10 - 12 %. I can live with that unless someone else has a better suggestion.

@mattiZed mattiZed requested a review from urschrei April 25, 2024 20:05
@urschrei
Copy link
Member

Why aren't our tests running 🤔

@urschrei
Copy link
Member

urschrei commented Apr 25, 2024

@mattiZed Thanks, this looks OK to me. Could you also update the changelog (under Unreleased)? Just a short entry noting the change and perf regression. I'll leave this open til tomorrow and then merge unless anyone else has input.

@mattiZed
Copy link
Contributor Author

@mattiZed Thanks, this looks OK to me. Could you also update the changelog (under Unreleased)? Just a short entry noting the change and perf regression. I'll leave this open til tomorrow and then merge unless anyone else has input.

Sure thing, done!

@urschrei urschrei added this pull request to the merge queue Apr 26, 2024
Merged via the queue into georust:main with commit b4436a7 Apr 26, 2024
1 check passed
@michaelkirk michaelkirk mentioned this pull request Apr 30, 2024
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