Skip to content

Commit 2e3f3e9

Browse files
Merge branch 'master' into sf-ankerl
2 parents 2e54842 + a2915f7 commit 2e3f3e9

19 files changed

+197
-161
lines changed

.clang-tidy

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ Checks: >
1313
-bugprone-forward-declaration-namespace,
1414
-bugprone-sizeof-expression,
1515
-bugprone-throw-keyword-missing,
16+
-bugprone-chained-comparison,
17+
-bugprone-incorrect-enable-if,
18+
-bugprone-switch-missing-default-case,
19+
-bugprone-empty-catch,
1620
-clang-analyzer-*,
1721
-clang-diagnostic-deprecated-declarations,
1822
-clang-diagnostic-constant-conversion,
@@ -49,11 +53,13 @@ Checks: >
4953
-misc-misplaced-const,
5054
-misc-definitions-in-headers,
5155
-misc-unused-parameters,
56+
-misc-include-cleaner,
5257
modernize-concat-nested-namespaces,
5358
modernize-use-using,
5459
performance-*,
55-
-performance-noexcept-move-constructor,
5660
-performance-no-int-to-ptr,
61+
-performance-enum-size,
62+
-performance-avoid-endl,
5763
readability-*,
5864
-readability-avoid-const-params-in-decls,
5965
-readability-braces-around-statements,
@@ -82,6 +88,10 @@ Checks: >
8288
-readability-make-member-function-const,
8389
-readability-redundant-string-init,
8490
-readability-non-const-parameter,
91+
-readability-redundant-inline-specifier,
92+
-readability-avoid-nested-conditional-operator,
93+
-readability-avoid-return-with-void-value,
94+
-readability-redundant-casting,
8595
-readability-static-accessed-through-instance
8696
8797
WarningsAsErrors: '*'

.github/workflows/osrm-backend.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,14 @@ jobs:
192192
CXXCOMPILER: clang++-15
193193
CUCUMBER_TIMEOUT: 60000
194194

195-
- name: clang-15-debug-clang-tidy
195+
- name: clang-18-debug-clang-tidy
196196
continue-on-error: false
197197
node: 18
198-
runs-on: ubuntu-22.04
198+
runs-on: ubuntu-24.04
199199
BUILD_TOOLS: ON
200200
BUILD_TYPE: Debug
201-
CCOMPILER: clang-15
202-
CXXCOMPILER: clang++-15
201+
CCOMPILER: clang-18
202+
CXXCOMPILER: clang++-18
203203
CUCUMBER_TIMEOUT: 60000
204204
ENABLE_CLANG_TIDY: ON
205205

@@ -656,7 +656,7 @@ jobs:
656656
path: pr
657657
- name: Install dependencies
658658
run: |
659-
python3 -m pip install "conan<2.0.0" "requests==2.31.0" "locust==2.28.0"
659+
python3 -m pip install "conan<2.0.0" "requests==2.31.0" "numpy==1.26.4"
660660
sudo apt-get update -y && sudo apt-get install ccache
661661
- name: Prepare data
662662
run: |

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- ADDED: Add support for opposite approach request parameter. [#6842](https://github.com/Project-OSRM/osrm-backend/pull/6842)
99
- ADDED: Add support for accessing edge flags in `process_segment` [#6658](https://github.com/Project-OSRM/osrm-backend/pull/6658)
1010
- Build:
11+
- CHANGED: Upgrade clang-format to version 15. [#6919](https://github.com/Project-OSRM/osrm-backend/pull/6919)
1112
- CHANGED: Use Debian Bookworm as base Docker image [#6904](https://github.com/Project-OSRM/osrm-backend/pull/6904)
1213
- CHANGED: Upgrade CI actions to latest versions [#6893](https://github.com/Project-OSRM/osrm-backend/pull/6893)
1314
- CHANGED: Remove outdated warnings #6894 [#6894](https://github.com/Project-OSRM/osrm-backend/pull/6894)
@@ -23,6 +24,9 @@
2324
- NodeJS:
2425
- CHANGED: Use node-api instead of NAN. [#6452](https://github.com/Project-OSRM/osrm-backend/pull/6452)
2526
- Misc:
27+
- FIXED: Fix bugprone-unused-return-value clang-tidy warning. [#6934](https://github.com/Project-OSRM/osrm-backend/pull/6934)
28+
- FIXED: Fix performance-noexcept-move-constructor clang-tidy warning. [#6931](https://github.com/Project-OSRM/osrm-backend/pull/6933)
29+
- FIXED: Fix performance-noexcept-swap clang-tidy warning. [#6931](https://github.com/Project-OSRM/osrm-backend/pull/6931)
2630
- CHANGED: Use custom struct instead of std::pair in QueryHeap. [#6921](https://github.com/Project-OSRM/osrm-backend/pull/6921)
2731
- CHANGED: Use std::string_view::starts_with instead of boost::starts_with. [#6918](https://github.com/Project-OSRM/osrm-backend/pull/6918)
2832
- CHANGED: Get rid of boost::math::constants::* and M_PI in favor of std::numbers. [#6916](https://github.com/Project-OSRM/osrm-backend/pull/6916)

include/extractor/serialization.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ inline void read(storage::tar::FileReader &reader,
215215
const std::string &name,
216216
detail::NameTableImpl<Ownership> &name_table)
217217
{
218-
std::string buffer;
219218
util::serialization::read(reader, name, name_table.indexed_data);
220219
}
221220
} // namespace osrm::extractor::serialization

include/server/http/header.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct header
1212
// explicitly use default copy c'tor as adding move c'tor
1313
header &operator=(const header &other) = default;
1414
header(std::string name, std::string value) : name(std::move(name)), value(std::move(value)) {}
15-
header(header &&other) : name(std::move(other.name)), value(std::move(other.value)) {}
15+
header(header &&other) noexcept : name(std::move(other.name)), value(std::move(other.value)) {}
1616

1717
void clear()
1818
{

include/storage/shared_memory.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class SharedMemory
6161
{
6262
shm = boost::interprocess::xsi_shared_memory(boost::interprocess::open_only, key);
6363

64-
util::Log(logDEBUG) << "opening " << (int)shm.get_shmid() << " from id " << (int)id;
64+
util::Log(logDEBUG) << "opening " << shm.get_shmid() << " from id " << (int)id;
6565

6666
region = boost::interprocess::mapped_region(shm, boost::interprocess::read_only);
6767
}

include/util/concurrent_id_map.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct ConcurrentIDMap
2626
mutable UpgradableMutex mutex;
2727

2828
ConcurrentIDMap() = default;
29-
ConcurrentIDMap(ConcurrentIDMap &&other)
29+
ConcurrentIDMap(ConcurrentIDMap &&other) noexcept
3030
{
3131
if (this != &other)
3232
{
@@ -36,7 +36,7 @@ struct ConcurrentIDMap
3636
data = std::move(other.data);
3737
}
3838
}
39-
ConcurrentIDMap &operator=(ConcurrentIDMap &&other)
39+
ConcurrentIDMap &operator=(ConcurrentIDMap &&other) noexcept
4040
{
4141
if (this != &other)
4242
{

include/util/deallocating_vector.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class DeallocatingVectorIterator
166166

167167
template <typename ElementT> class DeallocatingVector;
168168

169-
template <typename T> void swap(DeallocatingVector<T> &lhs, DeallocatingVector<T> &rhs);
169+
template <typename T> void swap(DeallocatingVector<T> &lhs, DeallocatingVector<T> &rhs) noexcept;
170170

171171
template <typename ElementT> class DeallocatingVector
172172
{
@@ -204,8 +204,8 @@ template <typename ElementT> class DeallocatingVector
204204
}
205205

206206
// moving is fine
207-
DeallocatingVector(DeallocatingVector &&other) { swap(other); }
208-
DeallocatingVector &operator=(DeallocatingVector &&other)
207+
DeallocatingVector(DeallocatingVector &&other) noexcept { swap(other); }
208+
DeallocatingVector &operator=(DeallocatingVector &&other) noexcept
209209
{
210210
swap(other);
211211
return *this;
@@ -221,9 +221,10 @@ template <typename ElementT> class DeallocatingVector
221221

222222
~DeallocatingVector() { clear(); }
223223

224-
friend void swap<>(DeallocatingVector<ElementT> &lhs, DeallocatingVector<ElementT> &rhs);
224+
friend void swap<>(DeallocatingVector<ElementT> &lhs,
225+
DeallocatingVector<ElementT> &rhs) noexcept;
225226

226-
void swap(DeallocatingVector<ElementT> &other)
227+
void swap(DeallocatingVector<ElementT> &other) noexcept
227228
{
228229
std::swap(current_size, other.current_size);
229230
bucket_list.swap(other.bucket_list);
@@ -342,7 +343,7 @@ template <typename ElementT> class DeallocatingVector
342343
}
343344
};
344345

345-
template <typename T> void swap(DeallocatingVector<T> &lhs, DeallocatingVector<T> &rhs)
346+
template <typename T> void swap(DeallocatingVector<T> &lhs, DeallocatingVector<T> &rhs) noexcept
346347
{
347348
lhs.swap(rhs);
348349
}

include/util/dynamic_graph.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ template <typename EdgeDataT> class DynamicGraph
154154
return *this;
155155
}
156156

157-
DynamicGraph(DynamicGraph &&other)
157+
DynamicGraph(DynamicGraph &&other) noexcept
158158
{
159159
number_of_nodes = other.number_of_nodes;
160160
// atomics can't be moved this is why we need an own constructor
@@ -164,7 +164,7 @@ template <typename EdgeDataT> class DynamicGraph
164164
edge_list = std::move(other.edge_list);
165165
}
166166

167-
DynamicGraph &operator=(DynamicGraph &&other)
167+
DynamicGraph &operator=(DynamicGraph &&other) noexcept
168168
{
169169
number_of_nodes = other.number_of_nodes;
170170
// atomics can't be moved this is why we need an own constructor

include/util/permutation.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ namespace osrm::util
1010

1111
namespace permutation_detail
1212
{
13-
template <typename T> static inline void swap(T &a, T &b) { std::swap(a, b); }
13+
template <typename T> static inline void swap(T &a, T &b) noexcept { std::swap(a, b); }
1414

15-
static inline void swap(std::vector<bool>::reference a, std::vector<bool>::reference b)
15+
static inline void swap(std::vector<bool>::reference a, std::vector<bool>::reference b) noexcept
1616
{
1717
std::vector<bool>::swap(a, b);
1818
}

scripts/ci/e2e_benchmark.py

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import requests
2+
import sys
3+
import random
4+
from collections import defaultdict
5+
import os
6+
import csv
7+
import numpy as np
8+
import time
9+
import argparse
10+
11+
class BenchmarkRunner:
12+
def __init__(self):
13+
self.coordinates = []
14+
self.tracks = defaultdict(list)
15+
16+
gps_traces_file_path = os.path.expanduser('~/gps_traces.csv')
17+
with open(gps_traces_file_path, 'r') as file:
18+
reader = csv.DictReader(file)
19+
for row in reader:
20+
coord = (float(row['Latitude']), float(row['Longitude']))
21+
self.coordinates.append(coord)
22+
self.tracks[row['TrackID']].append(coord)
23+
self.track_ids = list(self.tracks.keys())
24+
25+
def run(self, benchmark_name, host, num_requests, warmup_requests=50):
26+
for _ in range(warmup_requests):
27+
url = self.make_url(host, benchmark_name)
28+
_ = requests.get(url)
29+
30+
times = []
31+
32+
for _ in range(num_requests):
33+
url = self.make_url(host, benchmark_name)
34+
35+
start_time = time.time()
36+
response = requests.get(url)
37+
end_time = time.time()
38+
if response.status_code != 200:
39+
if benchmark_name == 'match':
40+
code = response.json()['code']
41+
if code == 'NoSegment' or code == 'NoMatch':
42+
continue
43+
raise Exception(f"Error: {response.status_code} {response.text}")
44+
times.append((end_time - start_time) * 1000) # convert to ms
45+
46+
return times
47+
48+
def make_url(self, host, benchmark_name):
49+
if benchmark_name == 'route':
50+
start = random.choice(self.coordinates)
51+
end = random.choice(self.coordinates)
52+
53+
start_coord = f"{start[1]:.6f},{start[0]:.6f}"
54+
end_coord = f"{end[1]:.6f},{end[0]:.6f}"
55+
return f"{host}/route/v1/driving/{start_coord};{end_coord}?overview=full&steps=true"
56+
elif benchmark_name == 'table':
57+
num_coords = random.randint(3, 100)
58+
selected_coords = random.sample(self.coordinates, num_coords)
59+
coords_str = ";".join([f"{coord[1]:.6f},{coord[0]:.6f}" for coord in selected_coords])
60+
return f"{host}/table/v1/driving/{coords_str}"
61+
elif benchmark_name == 'match':
62+
num_coords = random.randint(50, 100)
63+
track_id = random.choice(self.track_ids)
64+
track_coords = self.tracks[track_id][:num_coords]
65+
coords_str = ";".join([f"{coord[1]:.6f},{coord[0]:.6f}" for coord in track_coords])
66+
radiues_str = ";".join([f"{random.randint(5, 20)}" for _ in range(len(track_coords))])
67+
return f"{host}/match/v1/driving/{coords_str}?steps=true&radiuses={radiues_str}"
68+
elif benchmark_name == 'nearest':
69+
coord = random.choice(self.coordinates)
70+
coord_str = f"{coord[1]:.6f},{coord[0]:.6f}"
71+
return f"{host}/nearest/v1/driving/{coord_str}"
72+
elif benchmark_name == 'trip':
73+
num_coords = random.randint(2, 10)
74+
selected_coords = random.sample(self.coordinates, num_coords)
75+
coords_str = ";".join([f"{coord[1]:.6f},{coord[0]:.6f}" for coord in selected_coords])
76+
return f"{host}/trip/v1/driving/{coords_str}?steps=true"
77+
else:
78+
raise Exception(f"Unknown benchmark: {benchmark_name}")
79+
80+
def main():
81+
parser = argparse.ArgumentParser(description='Run GPS benchmark tests.')
82+
parser.add_argument('--host', type=str, required=True, help='Host URL')
83+
parser.add_argument('--method', type=str, required=True, choices=['route', 'table', 'match', 'nearest', 'trip'], help='Benchmark method')
84+
parser.add_argument('--num_requests', type=int, required=True, help='Number of requests to perform')
85+
86+
args = parser.parse_args()
87+
88+
random.seed(42)
89+
90+
runner = BenchmarkRunner()
91+
times = runner.run(args.method, args.host, args.num_requests)
92+
93+
print(f'Total: {np.sum(times)}ms')
94+
print(f"Min time: {np.min(times)}ms")
95+
print(f"Mean time: {np.mean(times)}ms")
96+
print(f"Median time: {np.median(times)}ms")
97+
print(f"95th percentile: {np.percentile(times, 95)}ms")
98+
print(f"99th percentile: {np.percentile(times, 99)}ms")
99+
print(f"Max time: {np.max(times)}ms")
100+
101+
if __name__ == '__main__':
102+
main()

scripts/ci/locustfile.py

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)