-
Notifications
You must be signed in to change notification settings - Fork 791
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a PROJ_DB_FAST_BUILD=ON/OFF CMake option (default OFF)
"Trigger" for this (pun intented) is that most of the time spent while building GDAL Docker image when cross-building to arm64 is spent on building proj.db (close to 7.5h for a target Ubuntu 24.04 arm64 !). Setting this new option should cut that to a few minutes. ``` .. option:: PROJ_DB_FAST_BUILD=OFF .. versionadded:: 9.5.1 By default, creation of :file:`proj.db` involves inserting consistency check triggers before inserting data records, to be able to catch potential inconsistencies. Such checks are useful for core PROJ developers when they update the database content, or for advanced PROJ users that customize the content of the database. However those checks come with a non-negligible cost. On modern hardware, building :file:`proj.db` with those checks enabled takes about 50 to 60 seconds (and on scenarios where PROJ is built for other architectures with full emulation, several hours). When setting this option to ON, those triggers are inserted after data records, which decreases the build time to about 3 seconds. In short, setting this option to ON is safe if you do not customize yourself the .sql files used to build :file:`proj.db` ``` Timings on my machine: - before this PR: ``` $ time make generate_proj_db [100%] Generating proj.db [100%] Built target generate_proj_db real 0m54,752s user 0m53,968s sys 0m0,648s $ md5sum data/proj.db beecdc018b4a5131229709b3c7747036 data/proj.db $ echo ".dump" | sqlite3 data/proj.db | md5sum 64e446efdc5c18e398cc7b6b2e4b3086 - ``` - with this PR, not setting PROJ_DB_FAST_BUILD (so OFF): Same as above - with this PR, setting PROJ_DB_FAST_BUILD=ON ``` $ cmake .. -DPROJ_DB_FAST_BUILD=ON $ time make generate_proj_db [100%] Generating proj.db [100%] Built target generate_proj_db real 0m3,243s user 0m2,876s sys 0m0,204s $ md5sum data/proj.db 1955dfdc3f7abada3890bf9b7592770a data/proj.db $ echo ".dump" | sqlite3 data/proj.db | md5sum 64e446efdc5c18e398cc7b6b2e4b3086 - ``` One can notice that the binary content of proj.db is not exactly the same, however the result of dumping it to SQL is exactly the same. The reason for the slight difference is that in PROJ_DB_FAST_BUILD=ON we also skip creating a fake table and trigger, which influences the "schema version number" of the SQLite3 database, which is a non significant difference. Cf the diff of the ``od -x`` output, which shows that only a few bytes in the SQLite3 header are different. ``` $ diff -u proj.db.slow.txt proj.db.fast.txt --- proj.db.slow.txt 2024-10-16 08:50:07.211601573 +0200 +++ proj.db.fast.txt 2024-10-16 08:50:16.155615860 +0200 @@ -1,9 +1,9 @@ 0000000 5153 694c 6574 6620 726f 616d 2074 0033 -0000020 0010 0101 4000 2020 0000 1100 0000 d208 -0000040 0000 0000 0000 0000 0000 6700 0000 0400 +0000020 0010 0101 4000 2020 0000 2500 0000 d208 +0000040 0000 0000 0000 0000 0000 6300 0000 0400 0000060 0000 0000 0000 0000 0000 0100 0000 0000 0000100 0000 0000 0000 0000 0000 0000 0000 0000 -0000120 0000 0000 0000 0000 0000 0000 0000 1100 +0000120 0000 0000 0000 0000 0000 0000 0000 2500 0000140 2e00 d93f 0005 0000 0f1a 007e 0000 d208 0000160 fb0f f60f f10f ec0f e70f e20f dd0f d80f 0000200 d30f ce0f c90f c40f bf0f ba0f b50f b00f ```
- Loading branch information
Showing
10 changed files
with
232 additions
and
192 deletions.
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
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,3 @@ | ||
ANALYZE; | ||
|
||
VACUUM; |
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,9 @@ | ||
|
||
CREATE TRIGGER conversion_method_check_insert_trigger_orthographic | ||
INSTEAD OF INSERT ON conversion | ||
BEGIN | ||
|
||
SELECT RAISE(ABORT, 'insert on conversion violates constraint: bad parameters for Orthographic') | ||
WHERE NEW.deprecated != 1 AND NEW.method_auth_name = 'EPSG' AND NEW.method_code = '9840' AND (NEW.method_name != 'Orthographic' OR NEW.param1_auth_name != 'EPSG' OR NEW.param1_code != '8801' OR NEW.param1_name != 'Latitude of natural origin' OR NEW.param1_value IS NULL OR NEW.param1_uom_auth_name IS NULL OR NEW.param1_uom_code IS NULL OR (SELECT type FROM unit_of_measure WHERE auth_name = NEW.param1_uom_auth_name AND code = NEW.param1_uom_code) != 'angle' OR NEW.param2_auth_name != 'EPSG' OR NEW.param2_code != '8802' OR NEW.param2_name != 'Longitude of natural origin' OR NEW.param2_value IS NULL OR NEW.param2_uom_auth_name IS NULL OR NEW.param2_uom_code IS NULL OR (SELECT type FROM unit_of_measure WHERE auth_name = NEW.param2_uom_auth_name AND code = NEW.param2_uom_code) != 'angle' OR NEW.param3_auth_name != 'EPSG' OR NEW.param3_code != '8806' OR NEW.param3_name != 'False easting' OR NEW.param3_value IS NULL OR NEW.param3_uom_auth_name IS NULL OR NEW.param3_uom_code IS NULL OR (SELECT type FROM unit_of_measure WHERE auth_name = NEW.param3_uom_auth_name AND code = NEW.param3_uom_code) != 'length' OR NEW.param4_auth_name != 'EPSG' OR NEW.param4_code != '8807' OR NEW.param4_name != 'False northing' OR NEW.param4_value IS NULL OR NEW.param4_uom_auth_name IS NULL OR NEW.param4_uom_code IS NULL OR (SELECT type FROM unit_of_measure WHERE auth_name = NEW.param4_uom_auth_name AND code = NEW.param4_uom_code) != 'length' OR NEW.param5_auth_name IS NOT NULL OR NEW.param5_code IS NOT NULL OR NEW.param5_name IS NOT NULL OR NEW.param5_value IS NOT NULL OR NEW.param5_uom_auth_name IS NOT NULL OR NEW.param5_uom_code IS NOT NULL OR NEW.param6_auth_name IS NOT NULL OR NEW.param6_code IS NOT NULL OR NEW.param6_name IS NOT NULL OR NEW.param6_value IS NOT NULL OR NEW.param6_uom_auth_name IS NOT NULL OR NEW.param6_uom_code IS NOT NULL OR NEW.param7_auth_name IS NOT NULL OR NEW.param7_code IS NOT NULL OR NEW.param7_name IS NOT NULL OR NEW.param7_value IS NOT NULL OR NEW.param7_uom_auth_name IS NOT NULL OR NEW.param7_uom_code IS NOT NULL); | ||
|
||
END; |
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
Oops, something went wrong.