Skip to content

Conversation

@Rejudge-F
Copy link
Contributor

@Rejudge-F Rejudge-F commented Jan 30, 2023

fix(json_render): json_render is not accurate enough for extremely small numbers. eg: fmt::format_to(std::back_inserter(buffer), FMT_COMPILE("{}"), double(0.0000000000017114087924596788)); you will get a result of 1.7114087924, this is a completely wrong result.

formatter params(width & precision chapter): https://en.cppreference.com/w/cpp/utility/format/formatter

Issue

#6513

Tasklist

Requirements / Relations

Link any requirements here. Other pull requests this PR is based on?

…all numbers. eg: fmt::format_to(std::back_inserter(buffer), FMT_COMPILE({}), double(0.0000000000017114087924596788)); you will get a result of 1.7114087924, this is a completely wrong result.
@danpat
Copy link
Member

danpat commented Jan 30, 2023

@Rejudge-F This introduces a C++20 construct, but so far, this codebase is C++17. @mjjbell @SiarheiFedartsou How do you feel about bumping the minimum C++ version needed?

@Rejudge-F
Copy link
Contributor Author

@Rejudge-F This introduces a C++20 construct, but so far, this codebase is C++17. @mjjbell @SiarheiFedartsou How do you feel about bumping the minimum C++ version needed?

I don't think we need to bump the minimum C++ version needed, because the format_to function used by osrm is supported by the third-party fmt-9.1.0(code's here: third_party/fmt-9.1.0 ).

The above reference to the cpp reference is for the convenience of explaining the format_to parameters

@SiarheiFedartsou
Copy link
Member

@danpat indeed, it seems @Rejudge-F is right and we can support it with C++17(on another hand std::format from C++20 would allow us to get rid from dependency). But in general I don't see a lot of reasons to not use C++20 at the moment - we don't have obligations to maintain compatibility with old compilers.

@Rejudge-F Rejudge-F force-pushed the bugfix-error_formatting_doubles branch from 7e0d760 to 16c5a64 Compare January 30, 2023 11:38
BOOST_CHECK_EQUAL(str, "42");
}

BOOST_AUTO_TEST_CASE(test_json_issue_6531) {
Copy link
Member

Choose a reason for hiding this comment

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

@Rejudge-F Cool that you found this g suffix! Thanks! May I ask you to add 3-4 test cases more in order to make sure that the rest of the things work as expected? e.g. 42.1, 42.0, 0.12345678912345?

Let me know if you don't have time on it and I will try to do that on my own.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will do it.

@Rejudge-F
Copy link
Contributor Author

@SiarheiFedartsou About this issue test cases has added.

@DennisOSRM
Copy link
Collaborator

Nice change.

@SiarheiFedartsou
Copy link
Member

Hey @Rejudge-F
I just re-run failing job - it seems there was some one-time issue, but it still fails due to precision issues in some of tests:

2023-02-01T13:03:49.2459832Z 1) Scenario: �[1mSpeed annotations should handle zero segments�[22m - �[90mfeatures/testbot/annotations.feature:96�[39m
2023-02-01T13:03:49.2460578Z    Step: �[1mWhen I route I should get�[22m - �[90mfeatures/testbot/annotations.feature:116�[39m
2023-02-01T13:03:49.2461198Z    Step Definition: �[90mfeatures/step_definitions/routing.js:4�[39m
2023-02-01T13:03:49.2461529Z    Message:
2023-02-01T13:03:49.2463027Z      �[31mTables were not identical:
2023-02-01T13:03:49.2463708Z      | from | to | route   | a:speed |     a:distance                  | a:duration | a:nodes |
2023-02-01T13:03:49.2464328Z      | a    | c  | abc,abc | 10:10   | (-) 249.987618946:299.962882039 | 25:30      | 1:2:3   |
2023-02-01T13:03:49.2464882Z      | a    | c  | abc,abc | 10:10   | (+) 249.9876189:299.962882      | 25:30      | 1:2:3   |�[39m

Will you be able to update it too please?

@Rejudge-F
Copy link
Contributor Author

Hey @Rejudge-F

I just re-run failing job - it seems there was some one-time issue, but it still fails due to precision issues in some of tests:


2023-02-01T13:03:49.2459832Z 1) Scenario: �[1mSpeed annotations should handle zero segments�[22m - �[90mfeatures/testbot/annotations.feature:96�[39m

2023-02-01T13:03:49.2460578Z    Step: �[1mWhen I route I should get�[22m - �[90mfeatures/testbot/annotations.feature:116�[39m

2023-02-01T13:03:49.2461198Z    Step Definition: �[90mfeatures/step_definitions/routing.js:4�[39m

2023-02-01T13:03:49.2461529Z    Message:

2023-02-01T13:03:49.2463027Z      �[31mTables were not identical:

2023-02-01T13:03:49.2463708Z      | from | to | route   | a:speed |     a:distance                  | a:duration | a:nodes |

2023-02-01T13:03:49.2464328Z      | a    | c  | abc,abc | 10:10   | (-) 249.987618946:299.962882039 | 25:30      | 1:2:3   |

2023-02-01T13:03:49.2464882Z      | a    | c  | abc,abc | 10:10   | (+) 249.9876189:299.962882      | 25:30      | 1:2:3   |�[39m

Will you be able to update it too please?

Willing to

@Rejudge-F
Copy link
Contributor Author

Rejudge-F commented Feb 2, 2023

I have fixed all cucumber issue.
detail:

Failures:

1) Scenario: Car - DC North capitol situation, two on one off - features/car/conditional_restrictions.feature:499
   Step: When I route I should get - features/car/conditional_restrictions.feature:539
   Step Definition: features/step_definitions/routing.js:4
   Message:
     Tables were not identical:
     | from | to |     route                                      |     turns                                   |
     | a    | e  | (-) cap south,florida nw,florida nw,florida ne | (-) depart,turn right,continue uturn,arrive |
     | a    | e  | (+) cap south,florida ne,florida ne            | (+) depart,turn left,arrive                 |
     | f    | d  |     cap north,florida nw,florida nw            |     depart,turn left,arrive                 |
     | e    | c  | (-) florida ne,florida nw,cap south,cap south  | (-) depart,continue uturn,turn right,arrive |
     | e    | c  | (+) florida ne,cap south,cap south             | (+) depart,turn left,arrive                 |

2) Scenario: Car - DC North capitol situation, one on two off - features/car/conditional_restrictions.feature:546
   Step: When I route I should get - features/car/conditional_restrictions.feature:586
   Step Definition: features/step_definitions/routing.js:4
   Message:
     Tables were not identical:
     | from | to |     route                                      |     turns                                         |
     | a    | e  |     cap south,florida ne,florida ne            |     depart,turn left,arrive                       |
     | f    | d  | (-) cap north,florida ne,florida ne,florida nw | (-) depart,turn sharp right,continue uturn,arrive |
     | f    | d  | (+) cap north,florida nw,florida nw            | (+) depart,turn left,arrive                       |
     | e    | c  |     florida ne,cap south,cap south             |     depart,turn left,arrive                       |

3) Scenario: Speed annotations should handle zero segments - features/testbot/annotations.feature:96
   Step: When I route I should get - features/testbot/annotations.feature:116
   Step Definition: features/step_definitions/routing.js:4
   Message:
     Tables were not identical:
     | from | to | route   | a:speed |     a:distance                  | a:duration | a:nodes |
     | a    | c  | abc,abc | 10:10   | (-) 249.987618946:299.962882039 | 25:30      | 1:2:3   |
     | a    | c  | abc,abc | 10:10   | (+) 249.9876189:299.962882      | 25:30      | 1:2:3   |

4) Scenario: Regression test - add source phantom properly (two phantoms on one edge) - features/testbot/matching.feature:792
   Step: When I match I should get - features/testbot/matching.feature:811
   Step Definition: features/step_definitions/matching.js:7
   Message:
     Tables were not identical:
     | trace | geometry             |     a:distance   | a:duration | a:weight | duration |
     | 2345  | 1.00018,1,1.000314,1 | (-) 14.914666491 | 1.4        | 1.4      | 1.4      |
     | 2345  | 1.00018,1,1.000314,1 | (+) 14.91466649  | 1.4        | 1.4      | 1.4      |
     | 4321  | 1.00027,1,1.000135,1 | (-) 15.025969972 | 1.5        | 1.5      | 1.5      |
     | 4321  | 1.00027,1,1.000135,1 | (+) 15.02596997  | 1.5        | 1.5      | 1.5      |

5) Scenario: Shortest via path with continuation, multiple waypoint snapping candidates - features/testbot/snap_intersection.feature:529
   Step: When I route I should get - features/testbot/snap_intersection.feature:566
   Step Definition: features/step_definitions/routing.js:4
   Message:
     Tables were not identical:
     | waypoints | route             |     time           |     weight        |
     | a,f       | ad,df,df          |     40s            |     40            |
     | f,k       | fj,kj,kj          |     65.6s          |     65.6          |
     | a,f,k     | ac,cf,cf,fj,kj,kj |     132.8s         |     132.8         |
     | k,f       | ik,fi,fi          |     54.3s          |     54.3          |
     | f,a       | ef,ae,ae          |     66.6s          |     66.6          |
     | k,f,a     | kj,fj,fj,ef,ae,ae | (-) 141.399999999s | (-) 141.399999999 |
     | k,f,a     | kj,fj,fj,ef,ae,ae | (+) 141.4s         | (+) 141.4         |

6) Scenario: Shortest via path with uturns, multiple waypoint snapping candidates - features/testbot/snap_intersection.feature:582
   Step: When I route I should get - features/testbot/snap_intersection.feature:622
   Step Definition: features/step_definitions/routing.js:4
   Message:
     Tables were not identical:
     | waypoints | route             |     time           |     weight        |
     | a,f       | ad,df,df          |     40s            |     40            |
     | f,k       | fj,kj,kj          |     65.6s          |     65.6          |
     | a,f,k     | ad,df,df,fj,kj,kj |     105.6s         |     105.6         |
     | k,f       | ik,fi,fi          |     54.3s          |     54.3          |
     | f,a       | ef,ae,ae          |     66.6s          |     66.6          |
     | k,f,a     | ik,fi,fi,ef,ae,ae | (-) 120.899999999s | (-) 120.899999999 |
     | k,f,a     | ik,fi,fi,ef,ae,ae | (+) 120.9s         | (+) 120.9         |

7) Scenario: Start and target on the same and adjacent edge - features/testbot/weight.feature:39
   Step: When I route I should get - features/testbot/weight.feature:54
   Step Definition: features/step_definitions/routing.js:4
   Message:
     Tables were not identical:
     | waypoints | route   | distances | weights | times   |     a:distance                | a:duration | a:weight | a:speed |
     | s,t       | abc,abc | 20m,0m    | 2,0     | 2s,0s   | (-) 20.034626629              | 2          | 2        | 10      |
     | s,t       | abc,abc | 20m,0m    | 2,0     | 2s,0s   | (+) 20.03462663               | 2          | 2        | 10      |
     | t,s       | abc,abc | 20m,0m    | 2,0     | 2s,0s   | (-) 20.034626629              | 2          | 2        | 10      |
     | t,s       | abc,abc | 20m,0m    | 2,0     | 2s,0s   | (+) 20.03462663               | 2          | 2        | 10      |
     | s,e       | abc,abc | 40m,0m    | 3.9,0   | 3.9s,0s | (-) 29.940636463:10.017313314 | 3:0.9      | 3:0.9    | 10:11.1 |
     | s,e       | abc,abc | 40m,0m    | 3.9,0   | 3.9s,0s | (+) 29.94063646:10.01731331   | 3:0.9      | 3:0.9    | 10:11.1 |
     | e,s       | abc,abc | 40m,0m    | 3.9,0   | 3.9s,0s | (-) 10.017313314:29.940636463 | 0.9:3      | 0.9:3    | 11.1:10 |
     | e,s       | abc,abc | 40m,0m    | 3.9,0   | 3.9s,0s | (+) 10.01731331:29.94063646   | 0.9:3      | 0.9:3    | 11.1:10 |

1351 scenarios (7 failed, 1344 passed)
7246 steps (7 failed, 1 skipped, 7238 passed)
5m12.590s

When I route I should get
| from | to | route | turns |
| a | e | cap south,florida nw,florida nw,florida ne | depart,turn right,continue uturn,arrive |
| a | e | cap south,florida ne,florida ne | depart,turn left,arrive |
Copy link
Member

Choose a reason for hiding this comment

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

I am curious how it is possible that it was changed due to changes in JSON rendering? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This case is torturing me non-stop hahahaha, do you have a good solution?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think I can try dropping CI caches. Sorry, I am a bit busy right now, but will try to do that this evening(not sure which time zone you are, it will be in ~8-10 hours).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then this issue will be handed over to you, and I will no longer submit relevant code. I'm in GMT+8

@SiarheiFedartsou
Copy link
Member

@Rejudge-F many thanks for this contribution!

@SiarheiFedartsou SiarheiFedartsou self-requested a review February 2, 2023 17:58
@SiarheiFedartsou SiarheiFedartsou merged commit ebd9ab4 into Project-OSRM:master Feb 2, 2023
@DennisOSRM
Copy link
Collaborator

Very nice contribution. Tyvm

@Rejudge-F Rejudge-F deleted the bugfix-error_formatting_doubles branch February 3, 2023 03:08
mattwigway pushed a commit to mattwigway/osrm-backend that referenced this pull request Jul 20, 2023
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.

4 participants