Skip to content
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

Performance improvements #38

Merged
merged 47 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
4bbd633
Add performance notes
boardend Feb 14, 2024
da72203
qgis-js performance measurement tool
boardend Feb 14, 2024
f3c39eb
Update Qt to 6.6.2
boardend Feb 19, 2024
6769c3a
Update emsdk to 3.1.37
boardend Feb 19, 2024
cf5bd14
Disable QGIS wcs provider because of compilation error
boardend Feb 26, 2024
69bc11b
Upgrade to vcpkg 2024.02.14
boardend Feb 26, 2024
b465eb4
Fix --preload-file for emcc 3.1.37
boardend Feb 29, 2024
25e0ba6
Remove QGIS_JS_QT / QT6_DIR / QT_HOST_PATH and Qt installation notes
boardend Feb 29, 2024
1519972
Remove qt-patches
boardend Feb 29, 2024
a01f88a
Adopt PROJ setup for new version
boardend Feb 29, 2024
8d051c3
Update qca port (based on QField's qca)
boardend Feb 29, 2024
aee12a5
Internalize qtbase 6.6.1 from vcpkg 2024.02.14
boardend Feb 29, 2024
e3522ec
Adapt qtbase 6.6.1 for emscripten build
boardend Feb 29, 2024
fbf6f81
Adapt vcpkg.json for internalized qtbase
boardend Feb 29, 2024
d5d98f1
Adapt qtkeychain-qt6 for internalized qtbase
boardend Feb 29, 2024
0d95a14
Adapt qgis-qt6 for internalized qtbase
boardend Feb 29, 2024
bdab0a5
Fix missing QT_LRELEASE_EXECUTABLE in qgis-qt6
boardend Feb 29, 2024
01e7323
Find QT_TOOLCHAIN_FILE without Qt6_DIR
boardend Feb 29, 2024
6eff3b7
Temporary disabling of debug builds
boardend Feb 29, 2024
8347c32
Update to emsdk 3.1.54
boardend Feb 29, 2024
eec5e8e
Unify target filename across all build types by setting OUTPUT_NAME
boardend Mar 1, 2024
ed53a97
Switch to worker.mjs suffix (change in emcc 3.1.52)
boardend Mar 1, 2024
0fb0f8e
Embind: Prevent allow_raw_pointers()
boardend Mar 1, 2024
fc86c2e
Add SIMD support
boardend Jan 18, 2024
4e8c89f
OUTPUT_NAME is only needed on dev builds
boardend Mar 1, 2024
61592ad
Switch to QgsMapRendererParallelJob
boardend Mar 1, 2024
048b81e
Adding some GDAL/OGR hints to improove GPKG speed
boardend Mar 1, 2024
1928c39
Preview Rendering based on "renderJob" API / QgisJobDataSrouce
boardend May 7, 2024
c0e5a52
Update to emscripten 3.1.59
boardend May 7, 2024
49bbecc
Upgrade to pnpm 9.1.0 and update all JS dependencies
boardend May 7, 2024
d992511
Remove traces of pre built Qt 6.6.2 "qt6"-port
boardend May 7, 2024
f719dc6
Allow up to 16 threads and use "threadPoolSize" also QgsApplication s…
boardend May 8, 2024
99c44a2
Prevent output duplication on error in compile action
boardend May 8, 2024
040bdfc
Switch to "mimalloc"
boardend May 8, 2024
44da157
Cleanup of CMake related files
boardend May 8, 2024
faf191c
ol: Add process indicator
boardend May 20, 2024
3969a45
Update to latest OpenLayers
boardend May 21, 2024
63c3f0e
Remove unused qgis-js.worker.mjs (see Emscripten changelog 3.1.58)
boardend May 21, 2024
c0a5e00
Remove explicit OUTPUT_NAME for dev build type (seems not needed anym…
boardend May 21, 2024
dff9618
Prevent blocking on QgisApi_renderImage / QgisApi_renderJob start
boardend May 22, 2024
91fde55
Remove Qt related stuff from GitHub "build" Action
boardend May 22, 2024
d0e0633
Update READMEs (Size and Libs)
boardend May 22, 2024
0e4b691
Try to clean up disk space to complete the 'build' Action
boardend May 22, 2024
23e404f
Ensure QT_TOOLCHAIN_FILE inclusion on the initial build in CMakeLists…
boardend May 23, 2024
b593aaf
Update performance.md
boardend Jun 2, 2024
08158bc
Fix typo in QgisJobDataSource file name
boardend Jun 2, 2024
412ba3f
Add note to job->start() on a worker thread
boardend Jun 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 4 additions & 48 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ concurrency:

jobs:
build-qgis-js:
env:
qt: "6.5.2"
qtModules: "qt5compat"
pythonVersion: "3.12"
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
Expand All @@ -44,51 +40,11 @@ jobs:
pkg-config
flex
bison
- name: Fix to install python with "actions/setup-python@v4" on act
if: ${{ env.ACT }}
run: |
# Hack to get setup-python to work on act
# (see https://github.com/nektos/act/issues/251)
if [ ! -f "/etc/lsb-release" ] ; then
echo "DISTRIB_RELEASE=20.04" > /etc/lsb-release
fi
- uses: actions/setup-python@v4
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
python-version: ${{env.pythonVersion}}
# - name: Restore Qt cache
# uses: actions/cache@v2
# id: cache-qt
# with:
# path: ${{runner.workspace}}/Qt/${{env.qt}}
# key: ${{runner.os}}-qt-${{env.qt}}
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
dir: "${{ github.workspace }}/build"
# cached: ${{steps.cache-qt.outputs.cache-hit}}
setup-python: "false"
set-env: "false"
# from https://ddalcino.github.io/aqt-list-server/
aqtversion: "==3.1.*"
version: ${{env.qt}}
host: "linux"
target: "desktop"
arch: "wasm_multithread"
# qt modules required by qgis-js
modules: ${{env.qtModules}}
# workaround for gcc_64 host tools (see https://github.com/jurplel/install-qt-action/issues/181)
py7zrversion: "==0.20.*"
extra: "--autodesktop"
- name: Patch Qt
run: |
(
cd ${{ github.workspace }}/build/Qt/${{env.qt}};
patch -p0 < ${{ github.workspace }}/build/qt-patches/egl.patch &&
patch -p0 < ${{ github.workspace }}/build/qt-patches/exceptions.patch
)
- name: Set QGIS_JS_QT
run: |
echo "QGIS_JS_QT=${{ github.workspace }}/build/Qt/${{env.qt}}" >> "$GITHUB_ENV"
tool-cache: false
swap-storage: false
- name: Setup node from package.json
uses: actions/setup-node@v4
with:
Expand Down
7 changes: 0 additions & 7 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
{
"name": "Linux",
"includePath": [
"${env:HOME}/Qt/6.5.2/wasm_multithread/include",
"${env:HOME}/Qt/6.5.2/wasm_multithread/include/QtCore",
"${env:HOME}/Qt/6.5.2/wasm_multithread/include/QtGui",
"${env:HOME}/Qt/6.5.2/wasm_multithread/include/QtWidgets",
"${env:HOME}/Qt/6.5.2/wasm_multithread/include/QtNetwork",
"${env:HOME}/Qt/6.5.2/wasm_multithread/include/QtConcurrent",
"${env:HOME}/Qt/6.5.2/wasm_multithread/include/QtXml",
"${workspaceFolder}/build/wasm/vcpkg_installed/wasm32-emscripten-qt-threads/include",
"${workspaceFolder}/build/wasm/vcpkg_installed/wasm32-emscripten-qt-threads/include/qgis",
"${workspaceFolder}/build/emsdk/upstream/emscripten/system/include"
Expand Down
2 changes: 0 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
"C_Cpp.clang_format_path": "${workspaceRoot}/node_modules/clang-format/bin/linux_x64/clang-format",
"cmake.cmakePath": "${workspaceFolder}/build/vcpkg/downloads/tools/cmake-3.27.1-linux/cmake-3.27.1-linux-x86_64/bin/cmake",
"cmake.environment": {
"QT_HOST_PATH": "${userHome}/Qt/6.5.2/gcc_64",
"Qt6_DIR": "${userHome}/Qt/6.5.2/wasm_multithread",
"VCPKG_BINARY_SOURCES": "clear"
},
"cmake.configureSettings": {
Expand Down
43 changes: 31 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ find_path(QGIS_INCLUDE_DIR
)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(qgis_debug_prefix "debug/") # debug lib is in different folder
set(qgis_debug_prefix "debug/") # debug lib is in different folder
endif()

find_library(
Expand All @@ -39,6 +39,17 @@ find_library(
NO_DEFAULT_PATH
)

# because on the initial build the Qt toolchain file is not yet generated and therefore not included by qgis-js.cmake
# this will ensure that the Qt toolchain file is included after qtbase is built
if(EXISTS ${QT_TOOLCHAIN_FILE})
set(QT_CHAINLOAD_TOOLCHAIN_FILE ${EMSCRIPTEN_TOOLCHAIN_FILE})
include(${QT_TOOLCHAIN_FILE})
else()
message(FATAL_ERROR "Could not find Qt toolchain file: ${QT_TOOLCHAIN_FILE}")
endif()

# since Qt 6.3 qt_standard_project_setup should be used so set some default values
qt_standard_project_setup()

set(QGISJS_SOURCES
src/qgis-js.cpp
Expand All @@ -52,8 +63,8 @@ qt_add_executable(qgis-js MANUAL_FINALIZATION ${QGISJS_SOURCES})
target_compile_options(qgis-js PRIVATE "-fwasm-exceptions")
set_target_properties(qgis-js PROPERTIES LINK_FLAGS "-fwasm-exceptions")

set_target_properties(qgis-js PROPERTIES LINK_FLAGS "--bind")
set_target_properties(qgis-js PROPERTIES LINK_FLAGS "--preload-file ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/proj@/proj --preload-file ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/qgis/resources/srs.db@/qgis/resources/srs.db")
target_compile_options(qgis-js PRIVATE "-msimd128")
set_target_properties(qgis-js PROPERTIES LINK_FLAGS "-msimd128")

target_include_directories(qgis-js PRIVATE ${QGIS_INCLUDE_DIR})
target_link_libraries(qgis-js PRIVATE ${QGIS_LIBRARY})
Expand All @@ -66,14 +77,13 @@ target_link_libraries(qgis-js PRIVATE
Qt6::Gui
Qt6::Core5Compat
Qt6::PrintSupport
Qt6::Widgets # because QgsApplication -> QApplication
Qt6::Widgets # because QgsApplication -> QApplication
)

set(QGIS_PROVIDERS_LIST
provider_arcgisfeatureserver
provider_arcgismapserver
provider_delimitedtext
provider_wcs
provider_wms
)

Expand Down Expand Up @@ -110,10 +120,11 @@ qt_finalize_executable(qgis-js)
# Flags set by Qt:
# -s PTHREAD_POOL_SIZE=4
# -s INITIAL_MEMORY=50MB
# -s EXPORTED_RUNTIME_METHODS=UTF16ToString,stringToUTF16,JSEvents,specialHTMLTargets
# -s EXPORTED_RUNTIME_METHODS=UTF16ToString,stringToUTF16,JSEvents,specialHTMLTargets,FS
# -s MAX_WEBGL_VERSION=2
# -s FETCH=1
# -s WASM_BIGINT=1
# -s STACK_SIZE=5MB
# -s MODULARIZE=1
# -s EXPORT_NAME=createQtAppInstance
# -s ALLOW_MEMORY_GROWTH
Expand All @@ -122,24 +133,27 @@ qt_finalize_executable(qgis-js)

# Emscripten Runtime
target_link_options(qgis-js PRIVATE "SHELL: \
-s EXPORT_ES6 \
-s STACK_SIZE=5242880" # 5M
-s EXPORT_ES6"
)

# FS (see https://emscripten.org/docs/api_reference/Filesystem-API.html)
# NOTE: EXTRA_EXPORTED_RUNTIME_METHODS is deprecated, but we need it for now in order to not overwrite the EXPORTED_RUNTIME_METHODS set by Qt
target_link_options(qgis-js PRIVATE "SHELL: \
-s EXTRA_EXPORTED_RUNTIME_METHODS=[FS] \
-s FORCE_FILESYSTEM=1"
)

# Threading (see https://emscripten.org/docs/porting/pthreads.html)
set(MINIMAL_THREAD_POOL_SIZE "4")
set(MAXIMAL_THREAD_POOL_SIZE "8")
set(MAXIMAL_THREAD_POOL_SIZE "16")
target_link_options(qgis-js PRIVATE "SHELL: \
-s PTHREAD_POOL_SIZE=\"Math.min(Math.max(((navigator&&navigator.hardwareConcurrency)||${MINIMAL_THREAD_POOL_SIZE}),${MINIMAL_THREAD_POOL_SIZE}),${MAXIMAL_THREAD_POOL_SIZE})\" \
-s PTHREAD_POOL_SIZE_STRICT=2 \
-s PTHREAD_POOL_DELAY_LOAD=1"
-s PTHREAD_POOL_DELAY_LOAD=1 \
-s MALLOC=mimalloc"
)

target_link_options(qgis-js PRIVATE "SHELL: \
--preload-file ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/proj@/proj \
--preload-file ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/qgis/resources/srs.db@/qgis/resources/srs.db"
)

# DWARF debug info (see https://developer.chrome.com/blog/faster-wasm-debugging/)
Expand All @@ -149,3 +163,8 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
-gsplit-dwarf \
-gpubnames")
endif()

# TODO remove this fix (see https://github.com/emscripten-core/emscripten/issues/21844)
target_link_options(qgis-js PRIVATE "SHELL: \
-s EXPORTED_FUNCTIONS=_main,__emscripten_thread_crashed,__embind_initialize_bindings"
)
Loading
Loading