Project-OSRM / osrm-backend

Open Source Routing Machine - C++ backend
http://map.project-osrm.org
BSD 2-Clause "Simplified" License
6.42k stars 3.4k forks source link

Use Lemire's fast check whether to escape a JSON string #6923

Closed DennisOSRM closed 5 months ago

DennisOSRM commented 5 months ago

Lemire explains the method in his recent blog post. Bottom line, it is faster.

Benchmark Results

Benchmark Base PR
alias aliased u32: 1082.07
plain u32: 1082.28
aliased double: 952.881
plain double: 954.315
aliased u32: 1088.98
plain u32: 1156.68
aliased double: 948.964
plain double: 951.851
json-render String: 6.65077ms
Stringstream: 9.38816ms
Vector: 6.83465ms
String: 6.62298ms
Stringstream: 9.41552ms
Vector: 6.93634ms
match_ch Default radius:
4.41722ms/req at 82 coordinate
0.0538685ms/coordinate
Radius 5m:
4.38879ms/req at 82 coordinate
0.0535219ms/coordinate
Radius 10m:
14.9413ms/req at 82 coordinate
0.182211ms/coordinate
Radius 15m:
36.589ms/req at 82 coordinate
0.446208ms/coordinate
Radius 30m:
312.676ms/req at 82 coordinate
3.81312ms/coordinate
Default radius:
4.40638ms/req at 82 coordinate
0.0537364ms/coordinate
Radius 5m:
4.39026ms/req at 82 coordinate
0.0535398ms/coordinate
Radius 10m:
15.0229ms/req at 82 coordinate
0.183206ms/coordinate
Radius 15m:
36.6518ms/req at 82 coordinate
0.446973ms/coordinate
Radius 30m:
312.225ms/req at 82 coordinate
3.80763ms/coordinate
match_mld Default radius:
2.77057ms/req at 82 coordinate
0.0337874ms/coordinate
Radius 5m:
2.8208ms/req at 82 coordinate
0.0344ms/coordinate
Radius 10m:
10.0691ms/req at 82 coordinate
0.122794ms/coordinate
Radius 15m:
25.7561ms/req at 82 coordinate
0.314099ms/coordinate
Radius 30m:
302.227ms/req at 82 coordinate
3.6857ms/coordinate
Default radius:
2.7439ms/req at 82 coordinate
0.0334622ms/coordinate
Radius 5m:
2.73356ms/req at 82 coordinate
0.0333361ms/coordinate
Radius 10m:
10.0565ms/req at 82 coordinate
0.12264ms/coordinate
Radius 15m:
25.6863ms/req at 82 coordinate
0.313247ms/coordinate
Radius 30m:
302.331ms/req at 82 coordinate
3.68697ms/coordinate
packedvector random write:
std::vector 9770.72 ms
util::packed_vector 81846 ms
slowdown: 8.37666
random read:
std::vector 8409.35 ms
util::packed_vector 33338.8 ms
slowdown: 3.96449
random write:
std::vector 9833.76 ms
util::packed_vector 81878.2 ms
slowdown: 8.32624
random read:
std::vector 8461.8 ms
util::packed_vector 33322.9 ms
slowdown: 3.93804
route_ch 1000 routes, 3 coordinates, no alternatives, overview=full, steps=true
510.386ms
0.510386ms/req
1000 routes, 2 coordinates, no alternatives, overview=full, steps=true
351.149ms
0.351149ms/req
1000 routes, 2 coordinates, 3 alternatives, overview=full, steps=true
627.407ms
0.627407ms/req
1000 routes, 3 coordinates, no alternatives, overview=false, steps=false
151.105ms
0.151105ms/req
1000 routes, 2 coordinates, no alternatives, overview=false, steps=false
97.3492ms
0.0973492ms/req
1000 routes, 2 coordinates, 3 alternatives, overview=false, steps=false
146.415ms
0.146415ms/req
1000 routes, 3 coordinates, no alternatives, overview=false, steps=false, radius=750
150.311ms
0.150311ms/req
1000 routes, 2 coordinates, no alternatives, overview=false, steps=false, radius=750
96.8538ms
0.0968538ms/req
1000 routes, 2 coordinates, 3 alternatives, overview=false, steps=false, radius=750
132.538ms
0.132538ms/req
1000 routes, 3 coordinates, no alternatives, overview=full, steps=true
511.762ms
0.511762ms/req
1000 routes, 2 coordinates, no alternatives, overview=full, steps=true
349.853ms
0.349853ms/req
1000 routes, 2 coordinates, 3 alternatives, overview=full, steps=true
643.417ms
0.643417ms/req
1000 routes, 3 coordinates, no alternatives, overview=false, steps=false
150.425ms
0.150425ms/req
1000 routes, 2 coordinates, no alternatives, overview=false, steps=false
96.5273ms
0.0965273ms/req
1000 routes, 2 coordinates, 3 alternatives, overview=false, steps=false
131.715ms
0.131715ms/req
1000 routes, 3 coordinates, no alternatives, overview=false, steps=false, radius=750
150.649ms
0.150649ms/req
1000 routes, 2 coordinates, no alternatives, overview=false, steps=false, radius=750
96.6212ms
0.0966212ms/req
1000 routes, 2 coordinates, 3 alternatives, overview=false, steps=false, radius=750
131.529ms
0.131529ms/req
route_mld 1000 routes, 3 coordinates, no alternatives, overview=full, steps=true
635.801ms
0.635801ms/req
1000 routes, 2 coordinates, no alternatives, overview=full, steps=true
435.188ms
0.435188ms/req
1000 routes, 2 coordinates, 3 alternatives, overview=full, steps=true
809.095ms
0.809095ms/req
1000 routes, 3 coordinates, no alternatives, overview=false, steps=false
266.64ms
0.26664ms/req
1000 routes, 2 coordinates, no alternatives, overview=false, steps=false
161.2ms
0.1612ms/req
1000 routes, 2 coordinates, 3 alternatives, overview=false, steps=false
287.36ms
0.28736ms/req
1000 routes, 3 coordinates, no alternatives, overview=false, steps=false, radius=750
264.154ms
0.264154ms/req
1000 routes, 2 coordinates, no alternatives, overview=false, steps=false, radius=750
160.813ms
0.160813ms/req
1000 routes, 2 coordinates, 3 alternatives, overview=false, steps=false, radius=750
286.529ms
0.286529ms/req
1000 routes, 3 coordinates, no alternatives, overview=full, steps=true
638.876ms
0.638876ms/req
1000 routes, 2 coordinates, no alternatives, overview=full, steps=true
435.419ms
0.435419ms/req
1000 routes, 2 coordinates, 3 alternatives, overview=full, steps=true
810.814ms
0.810814ms/req
1000 routes, 3 coordinates, no alternatives, overview=false, steps=false
262.779ms
0.262779ms/req
1000 routes, 2 coordinates, no alternatives, overview=false, steps=false
161.743ms
0.161743ms/req
1000 routes, 2 coordinates, 3 alternatives, overview=false, steps=false
286.937ms
0.286937ms/req
1000 routes, 3 coordinates, no alternatives, overview=false, steps=false, radius=750
255.757ms
0.255757ms/req
1000 routes, 2 coordinates, no alternatives, overview=false, steps=false, radius=750
159.964ms
0.159964ms/req
1000 routes, 2 coordinates, 3 alternatives, overview=false, steps=false, radius=750
284.179ms
0.284179ms/req
rtree 1 result:
206.318ms -> 0.0206318 ms/query
10 results:
241.795ms -> 0.0241795 ms/query
1 result:
208.932ms -> 0.0208932 ms/query
10 results:
245.349ms -> 0.0245349 ms/query