Skip to content

Commit 89435aa

Browse files
Add new randomized benchmarks (#6929)
1 parent 0cbb23a commit 89435aa

File tree

6 files changed

+639
-38
lines changed

6 files changed

+639
-38
lines changed

.github/workflows/osrm-backend.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -645,8 +645,10 @@ jobs:
645645
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
646646
PR_NUMBER: ${{ github.event.pull_request.number }}
647647
GITHUB_REPOSITORY: ${{ github.repository }}
648+
RUN_BIG_BENCHMARK: ${{ contains(github.event.pull_request.labels.*.name, 'Performance') }}
648649
steps:
649650
- name: Enable data.osm.pbf cache
651+
if: ${{ ! env.RUN_BIG_BENCHMARK }}
650652
uses: actions/cache@v4
651653
with:
652654
path: ~/data.osm.pbf
@@ -678,10 +680,18 @@ jobs:
678680
sudo apt-get update -y && sudo apt-get install ccache
679681
- name: Prepare data
680682
run: |
681-
if [ ! -f "~/data.osm.pbf" ]; then
682-
wget http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf -O ~/data.osm.pbf
683+
if [ "$RUN_BIG_BENCHMARK" = "true" ]; then
684+
rm -rf ~/data.osm.pbf
685+
wget http://download.geofabrik.de/europe/poland-latest.osm.pbf -O ~/data.osm.pbf --quiet
686+
gunzip -c ./pr/test/data/poland_gps_traces.csv.gz > ~/gps_traces.csv
687+
else
688+
if [ ! -f "~/data.osm.pbf" ]; then
689+
wget http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf -O ~/data.osm.pbf
690+
else
691+
echo "Using cached data.osm.pbf"
692+
fi
693+
gunzip -c ./pr/test/data/berlin_gps_traces.csv.gz > ~/gps_traces.csv
683694
fi
684-
gunzip -c ./pr/test/data/berlin_gps_traces.csv.gz > ~/gps_traces.csv
685695
- name: Prepare environment
686696
run: |
687697
echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV

scripts/ci/download_gps_traces.py

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,43 @@
44
import sys
55
import argparse
66

7-
def get_osm_gps_traces(min_lon, min_lat, max_lon, max_lat):
7+
def get_osm_gps_traces(bboxes):
88
url = 'https://api.openstreetmap.org/api/0.6/trackpoints'
99
traces = []
1010

1111
lon_step = 0.25
1212
lat_step = 0.25
13-
14-
current_min_lon = min_lon
1513

16-
while current_min_lon < max_lon:
17-
current_max_lon = min(current_min_lon + lon_step, max_lon)
14+
for bbox in bboxes:
15+
min_lon, min_lat, max_lon, max_lat = map(float, bbox.split(','))
1816

19-
current_min_lat = min_lat
20-
while current_min_lat < max_lat:
21-
current_max_lat = min(current_min_lat + lat_step, max_lat)
22-
23-
bbox = f'{current_min_lon},{current_min_lat},{current_max_lon},{current_max_lat}'
24-
print(f"Requesting bbox: {bbox}", file=sys.stderr)
25-
26-
params = {
27-
'bbox': bbox,
28-
'page': 0
29-
}
30-
headers = {
31-
'Accept': 'application/xml'
32-
}
33-
34-
response = requests.get(url, params=params, headers=headers)
35-
if response.status_code == 200:
36-
traces.append(response.content)
37-
else:
38-
print(f"Error fetching data for bbox {bbox}: {response.status_code} {response.text}", file=sys.stderr)
17+
current_min_lon = min_lon
18+
while current_min_lon < max_lon:
19+
current_max_lon = min(current_min_lon + lon_step, max_lon)
3920

40-
current_min_lat += lat_step
41-
current_min_lon += lon_step
21+
current_min_lat = min_lat
22+
while current_min_lat < max_lat:
23+
current_max_lat = min(current_min_lat + lat_step, max_lat)
24+
25+
bbox_str = f'{current_min_lon},{current_min_lat},{current_max_lon},{current_max_lat}'
26+
print(f"Requesting bbox: {bbox_str}", file=sys.stderr)
27+
28+
params = {
29+
'bbox': bbox_str,
30+
'page': 0
31+
}
32+
headers = {
33+
'Accept': 'application/xml'
34+
}
35+
36+
response = requests.get(url, params=params, headers=headers)
37+
if response.status_code == 200:
38+
traces.append(response.content)
39+
else:
40+
print(f"Error fetching data for bbox {bbox_str}: {response.status_code} {response.text}", file=sys.stderr)
41+
42+
current_min_lat += lat_step
43+
current_min_lon += lon_step
4244

4345
return traces
4446

@@ -68,15 +70,12 @@ def save_to_csv(data, file):
6870
writer.writerows(data)
6971

7072
if __name__ == '__main__':
71-
parser = argparse.ArgumentParser(description='Fetch and output OSM GPS traces for a given bounding box.')
72-
parser.add_argument('min_lon', type=float, help='Minimum longitude of the bounding box')
73-
parser.add_argument('min_lat', type=float, help='Minimum latitude of the bounding box')
74-
parser.add_argument('max_lon', type=float, help='Maximum longitude of the bounding box')
75-
parser.add_argument('max_lat', type=float, help='Maximum latitude of the bounding box')
73+
parser = argparse.ArgumentParser(description='Fetch and output OSM GPS traces for given bounding boxes.')
74+
parser.add_argument('bboxes', nargs='+', help='Bounding boxes in the format min_lon,min_lat,max_lon,max_lat')
7675

7776
args = parser.parse_args()
7877

79-
gpx_data_traces = get_osm_gps_traces(args.min_lon, args.min_lat, args.max_lon, args.max_lat)
78+
gpx_data_traces = get_osm_gps_traces(args.bboxes)
8079
print(f"Collected {len(gpx_data_traces)} trace segments", file=sys.stderr)
8180

8281
all_data = []

scripts/ci/run_benchmarks.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ function run_benchmarks_for_folder {
4242
measure_peak_ram_and_time "$BINARIES_FOLDER/osrm-customize $FOLDER/data.osrm" "$RESULTS_FOLDER/osrm_customize.bench"
4343
measure_peak_ram_and_time "$BINARIES_FOLDER/osrm-contract $FOLDER/data.osrm" "$RESULTS_FOLDER/osrm_contract.bench"
4444

45+
for BENCH in nearest table trip route match; do
46+
./$BENCHMARKS_FOLDER/bench "$FOLDER/data.osrm" mld ~/gps_traces.csv ${BENCH} > "$RESULTS_FOLDER/random_${BENCH}_mld.bench" || true
47+
./$BENCHMARKS_FOLDER/bench "$FOLDER/data.osrm" ch ~/gps_traces.csv ${BENCH} > "$RESULTS_FOLDER/random_${BENCH}_ch.bench" || true
48+
done
49+
50+
4551
for ALGORITHM in ch mld; do
4652
$BINARIES_FOLDER/osrm-routed --algorithm $ALGORITHM $FOLDER/data.osrm &
4753
OSRM_ROUTED_PID=$!
@@ -59,8 +65,6 @@ function run_benchmarks_for_folder {
5965

6066
kill -9 $OSRM_ROUTED_PID
6167
done
62-
63-
6468
}
6569

6670
run_benchmarks_for_folder $1 "${1}_results" $2

src/benchmarks/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ target_link_libraries(rtree-bench
1818
${TBB_LIBRARIES}
1919
${MAYBE_SHAPEFILE})
2020

21+
2122
add_executable(match-bench
2223
EXCLUDE_FROM_ALL
2324
${MatchBenchmarkSources}
@@ -35,13 +36,26 @@ add_executable(route-bench
3536
route.cpp
3637
$<TARGET_OBJECTS:UTIL>)
3738

39+
3840
target_link_libraries(route-bench
3941
osrm
4042
${BOOST_BASE_LIBRARIES}
4143
${CMAKE_THREAD_LIBS_INIT}
4244
${TBB_LIBRARIES}
4345
${MAYBE_SHAPEFILE})
4446

47+
add_executable(bench
48+
EXCLUDE_FROM_ALL
49+
bench.cpp
50+
$<TARGET_OBJECTS:UTIL>)
51+
52+
target_link_libraries(bench
53+
osrm
54+
${BOOST_BASE_LIBRARIES}
55+
${CMAKE_THREAD_LIBS_INIT}
56+
${TBB_LIBRARIES}
57+
${MAYBE_SHAPEFILE})
58+
4559
add_executable(json-render-bench
4660
EXCLUDE_FROM_ALL
4761
json_render.cpp
@@ -85,5 +99,6 @@ add_custom_target(benchmarks
8599
packedvector-bench
86100
match-bench
87101
route-bench
102+
bench
88103
json-render-bench
89104
alias-bench)

0 commit comments

Comments
 (0)