-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
CI: add benchmark test suite #8538
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e41f6fc
setdevenv.sh: do not use unbound variables
rouault bd1c534
gdal.cmake: automatically enable SQLite driver if -DOGR_ENABLE_DRIVER…
rouault b880cad
autotest: add basic benchmark/
rouault 8a819bf
CI: add benchmark
rouault 974175b
benchmarks/test.sh: use --benchmark-timer=time.process_time
rouault b0f6525
benchmarks/test.sh: bump tolerance to 20%
rouault File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
CMAKE_ARGS=( | ||
"-DUSE_CCACHE=ON" \ | ||
"-DCMAKE_BUILD_TYPE=Release" \ | ||
"-DCMAKE_INSTALL_PREFIX=/usr" \ | ||
"-DGDAL_USE_TIFF_INTERNAL=ON" \ | ||
"-DGDAL_USE_GEOTIFF_INTERNAL=ON" \ | ||
"-DECW_ROOT=/opt/libecwj2-3.3" \ | ||
"-DMRSID_ROOT=/usr/local" \ | ||
"-DFileGDB_ROOT=/usr/local/FileGDB_API" \ | ||
"-DBUILD_CSHARP_BINDINGS=OFF" \ | ||
"-DBUILD_JAVA_BINDINGS=OFF" \ | ||
"-DGDAL_BUILD_OPTIONAL_DRIVERS=OFF" \ | ||
"-DOGR_BUILD_OPTIONAL_DRIVERS=OFF" \ | ||
"-DOGR_ENABLE_DRIVER_GPKG=ON" \ | ||
) | ||
|
||
cmake ${GDAL_SOURCE_DIR:=..} \ | ||
"${CMAKE_ARGS[@]}" | ||
|
||
make -j$(nproc) | ||
|
||
mkdir old_version | ||
cd old_version | ||
# To be updated with a true reference branch and commit | ||
git clone https://github.com/rouault/gdal | ||
cd gdal | ||
git checkout b880cad693cd6cec0b0c90422cc6430121787ce4 | ||
mkdir build | ||
cd build | ||
|
||
cmake .. \ | ||
"${CMAKE_ARGS[@]}" | ||
|
||
make -j$(nproc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
BENCHMARK_STORAGE="file:///tmp" | ||
|
||
# Use time.process_time for more reliability on VMs | ||
BENCHMARK_OPTIONS=( | ||
"--benchmark-storage=${BENCHMARK_STORAGE}" \ | ||
"--benchmark-timer=time.process_time" \ | ||
) | ||
|
||
# Dry run to hopefully stabilize later timings | ||
(cd old_version/gdal/build; source ../scripts/setdevenv.sh; pytest autotest/benchmark "${BENCHMARK_OPTIONS[@]}" --capture=no -ra -vv) | ||
|
||
# Run reference (old) build and save its results | ||
(cd old_version/gdal/build; source ../scripts/setdevenv.sh; pytest autotest/benchmark "${BENCHMARK_OPTIONS[@]}" --benchmark-save=ref --capture=no -ra -vv) | ||
|
||
# Run target build and compare its results to the reference one. | ||
# Fail if we get results 20% slower or more. | ||
# Retry if that fails a first time. | ||
BENCHMARK_COMPARE_OPTIONS=( | ||
"--benchmark-compare-fail=min:20%" \ | ||
"--benchmark-compare=0001_ref" \ | ||
) | ||
|
||
(source ${GDAL_SOURCE_DIR:=..}/scripts/setdevenv.sh; pytest autotest/benchmark "${BENCHMARK_OPTIONS[@]}" "${BENCHMARK_COMPARE_OPTIONS[@]}" --capture=no -ra -vv || (echo "Retrying..."; pytest autotest/benchmark "${BENCHMARK_OPTIONS[@]}" "${BENCHMARK_COMPARE_OPTIONS[@]}" --capture=no -ra -vv)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env pytest | ||
# -*- coding: utf-8 -*- | ||
############################################################################### | ||
# $Id$ | ||
# | ||
# Project: GDAL/OGR Test Suite | ||
# Purpose: Benchmarking | ||
# Author: Even Rouault <even dot rouault at spatialys.com> | ||
# | ||
############################################################################### | ||
# Copyright (c) 2023, Even Rouault <even dot rouault at spatialys.com> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a | ||
# copy of this software and associated documentation files (the "Software"), | ||
# to deal in the Software without restriction, including without limitation | ||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
# and/or sell copies of the Software, and to permit persons to whom the | ||
# Software is furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included | ||
# in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
# DEALINGS IN THE SOFTWARE. | ||
############################################################################### | ||
|
||
import os | ||
|
||
from osgeo import gdal | ||
|
||
|
||
def pytest_report_header(config): | ||
gdal_header_info = "" | ||
|
||
if os.path.exists("/sys/devices/system/cpu/intel_pstate/no_turbo"): | ||
content = open("/sys/devices/system/cpu/intel_pstate/no_turbo", "rb").read() | ||
if content[0] == b"0"[0]: | ||
gdal_header_info += "\n" | ||
gdal_header_info += "WARNING WARNING\n" | ||
gdal_header_info += "---------------\n" | ||
gdal_header_info += "Intel TurboBoost is enabled. Benchmarking results will not be accurate.\n" | ||
gdal_header_info += "Disable TurboBoost with: 'echo 1 | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo'\n" | ||
gdal_header_info += "---------------\n" | ||
gdal_header_info += "WARNING WARNING\n" | ||
|
||
if "debug" in gdal.VersionInfo(""): | ||
gdal_header_info += "WARNING: Running benchmarks on debug build. Results will not be accurate.\n" | ||
|
||
return gdal_header_info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/usr/bin/env pytest | ||
# -*- coding: utf-8 -*- | ||
############################################################################### | ||
# $Id$ | ||
# | ||
# Project: GDAL/OGR Test Suite | ||
# Purpose: Benchmarking of gdalwarp | ||
# Author: Even Rouault <even dot rouault at spatialys.com> | ||
# | ||
############################################################################### | ||
# Copyright (c) 2023, Even Rouault <even dot rouault at spatialys.com> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a | ||
# copy of this software and associated documentation files (the "Software"), | ||
# to deal in the Software without restriction, including without limitation | ||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
# and/or sell copies of the Software, and to permit persons to whom the | ||
# Software is furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included | ||
# in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
# DEALINGS IN THE SOFTWARE. | ||
############################################################################### | ||
|
||
import gdaltest | ||
import pytest | ||
|
||
from osgeo import gdal, osr | ||
|
||
# Must be set to run the test_XXX functions under the benchmark fixture | ||
pytestmark = pytest.mark.usefixtures("decorate_with_benchmark") | ||
|
||
|
||
@pytest.fixture() | ||
def source_ds_filename(tmp_vsimem): | ||
filename = str(tmp_vsimem / "source.tif") | ||
if "debug" in gdal.VersionInfo(""): | ||
size = 1024 | ||
else: | ||
size = 4096 | ||
ds = gdal.GetDriverByName("GTiff").Create( | ||
filename, size, size, 3, options=["TILED=YES"] | ||
) | ||
srs = osr.SpatialReference() | ||
srs.ImportFromEPSG(32631) | ||
ds.SetSpatialRef(srs) | ||
ds.SetGeoTransform([400000, 1, 0, 4500000, 0, -1]) | ||
ds.GetRasterBand(1).Fill(1) | ||
ds.GetRasterBand(2).Fill(2) | ||
ds.GetRasterBand(3).Fill(3) | ||
ds = None | ||
return filename | ||
|
||
|
||
@pytest.mark.parametrize("num_threads", ["1", "ALL_CPUS"]) | ||
@pytest.mark.parametrize("resample_alg", ["near", "cubic"]) | ||
def test_gdalwarp(tmp_vsimem, source_ds_filename, num_threads, resample_alg): | ||
filename = str(tmp_vsimem / "test_gdalwarp.tif") | ||
if gdal.VSIStatL(filename): | ||
gdal.Unlink(filename) | ||
with gdaltest.config_option("GDAL_NUM_THREADS", num_threads): | ||
gdal.Warp( | ||
filename, | ||
source_ds_filename, | ||
options=f"-co TILED=YES -r {resample_alg} -t_srs EPSG:4326", | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move into
test.sh
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this can be done under Docker. Anyway it doesn't look like this is even hit (perhaps because we already run in a container/VM that doesn't expose turboboost setting)