From 255b868b839648ecd9a611367fb663bfbc9ab895 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Mon, 8 Jan 2024 20:59:49 +0100 Subject: [PATCH 1/5] ROStr/ROVar: Make them threadsafe --- Packages/MIES/MIES_GlobalStringAndVariableAccess.ipf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Packages/MIES/MIES_GlobalStringAndVariableAccess.ipf b/Packages/MIES/MIES_GlobalStringAndVariableAccess.ipf index 083aa9ad27..894f84b172 100644 --- a/Packages/MIES/MIES_GlobalStringAndVariableAccess.ipf +++ b/Packages/MIES/MIES_GlobalStringAndVariableAccess.ipf @@ -106,11 +106,11 @@ End /// @brief Helper function to get read-only access to a global variable /// /// @param path absolute path to a global variable -Function ROVar(path) +threadsafe Function ROVar(path) string path NVAR/Z var = $path - ASSERT(NVAR_Exists(var), "Could not recreate " + path) + ASSERT_TS(NVAR_Exists(var), "Could not recreate " + path) return var End @@ -118,11 +118,11 @@ End /// @brief Helper function to get read-only access to a global string /// /// @param path absolute path to a global string -Function/S ROStr(path) +threadsafe Function/S ROStr(path) string path SVAR/Z str = $path - ASSERT(SVAR_Exists(str), "Could not recreate " + path) + ASSERT_TS(SVAR_Exists(str), "Could not recreate " + path) return str End From eec8a1ef53c9e5897226135e75c24d4c343b1521 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Mon, 8 Jan 2024 21:00:59 +0100 Subject: [PATCH 2/5] GetIgorProBuildVersion: Make it threadsafe --- Packages/MIES/MIES_Utilities.ipf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/MIES/MIES_Utilities.ipf b/Packages/MIES/MIES_Utilities.ipf index 50bb0a1336..9250330fea 100644 --- a/Packages/MIES/MIES_Utilities.ipf +++ b/Packages/MIES/MIES_Utilities.ipf @@ -2827,7 +2827,7 @@ End /// /// This allows to distinguish different builds from the same major/minor /// version. -Function/S GetIgorProBuildVersion() +threadsafe Function/S GetIgorProBuildVersion() return StringByKey("BUILD", IgorInfo(0)) End From 491d0bea94b340a7780ec732a62d7cd3f5a44b9d Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Mon, 8 Jan 2024 23:18:00 +0100 Subject: [PATCH 3/5] GetIgorProBuildVersion: Prefer it --- Packages/MIES/MIES_CheckInstallation.ipf | 2 +- Packages/MIES/MIES_Utilities.ipf | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Packages/MIES/MIES_CheckInstallation.ipf b/Packages/MIES/MIES_CheckInstallation.ipf index c0de2da9a4..3890c40ad1 100644 --- a/Packages/MIES/MIES_CheckInstallation.ipf +++ b/Packages/MIES/MIES_CheckInstallation.ipf @@ -176,7 +176,7 @@ Function CHI_CheckInstallation() CHI_InitInstallationState(state) info = IgorInfo(0) - igorBuild = StringByKey("BUILD", info) + igorBuild = GetIgorProBuildVersion() if(!isEmpty(igorBuild)) igorBuild = ", " + igorBuild diff --git a/Packages/MIES/MIES_Utilities.ipf b/Packages/MIES/MIES_Utilities.ipf index 9250330fea..8501c274df 100644 --- a/Packages/MIES/MIES_Utilities.ipf +++ b/Packages/MIES/MIES_Utilities.ipf @@ -180,7 +180,7 @@ Function ASSERT(variable var, string errorMsg, [variable extendedOutput]) printf "DAQ: [%s]\r", RemoveEnding(TextWaveToList(daqStates, ";"), ";") printf "Testpulse: [%s]\r", RemoveEnding(TextWaveToList(tpStates, ";"), ";") printf "Experiment: %s (%s)\r", GetExperimentName(), GetExperimentFileType() - printf "Igor Pro version: %s (%s)\r", GetIgorProVersion(), StringByKey("BUILD", IgorInfo(0)) + printf "Igor Pro version: %s (%s)\r", GetIgorProVersion(), GetIgorProBuildVersion() print "MIES version:" print miesVersionStr print "################################" @@ -261,7 +261,7 @@ threadsafe Function ASSERT_TS(variable var, string errorMsg, [variable extendedO print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" printf "Time: %s\r", GetIso8601TimeStamp(localTimeZone = 1) printf "Experiment: %s (%s)\r", GetExperimentName(), GetExperimentFileType() - printf "Igor Pro version: %s (%s)\r", GetIgorProVersion(), StringByKey("BUILD", IgorInfo(0)) + printf "Igor Pro version: %s (%s)\r", GetIgorProVersion(), GetIgorProBuildVersion() print "################################" LOG_AddEntry(PACKAGE_MIES, LOG_ACTION_ASSERT, stacktrace = 1, keys = {LOG_MESSAGE_KEY}, values = {errorMsg}) From 5cf0aadaddd19ea258426453534319aacc773aee Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Mon, 8 Jan 2024 23:25:06 +0100 Subject: [PATCH 4/5] GetIgorInfo: Cache the IgorInfo output It turns out that calling IgorInfo with selector 3 takes around 50ms. As we call that quite often, let's cache it's value. Timing differences: Function Dostuff() variable ref = stopmsTimer(-2) print GetIgorProVersion() printf "%g [s]\r", (stopmsTimer(-2) - ref) / 1e6 ref = stopmsTimer(-2) print IgorInfo(3) printf "%g [s]\r", (stopmsTimer(-2) - ref) / 1e6 End gives dostuff() 9.0.6.1 0.0011045 [s] OS:Microsoft Windows 10 Pro (22H2);OSVERSION:10.0.19045.3803;LOCALE:US;IGORFILEVERSION:9.0.6.1; 0.141226 [s] --- Packages/MIES/MIES_Cache.ipf | 16 ++++++++++++++++ Packages/MIES/MIES_Utilities.ipf | 22 ++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/Packages/MIES/MIES_Cache.ipf b/Packages/MIES/MIES_Cache.ipf index 03a1ba4bd5..cfe0cb91d0 100644 --- a/Packages/MIES/MIES_Cache.ipf +++ b/Packages/MIES/MIES_Cache.ipf @@ -419,6 +419,22 @@ Function/S CA_PSXAnalyzePeaks(string comboKey, string psxParameters) return CA_PSXBaseKey(comboKey, psxParameters) + " Analyze Peaks " + ":Version 1" End +/// @brief Return the key for the igor info entries +threadsafe Function/S CA_IgorInfoKey(variable selector) + + string key + + // only add new selectors if their output is fixed for the current IP session + switch(selector) + case 0: // fallthrough-by-design + case 3: + sprintf key, "IgorInfo(%d):Version 1", selector + return key + default: + ASSERT_TS(0, "Unimplemented selector") + endswitch +End + /// @} /// @brief Make space for one new entry in the cache waves diff --git a/Packages/MIES/MIES_Utilities.ipf b/Packages/MIES/MIES_Utilities.ipf index 8501c274df..386216038e 100644 --- a/Packages/MIES/MIES_Utilities.ipf +++ b/Packages/MIES/MIES_Utilities.ipf @@ -2818,9 +2818,27 @@ Function GetArchitectureBits() #endif End +/// @brief Return the given IgorInfo (cached) +/// +/// This is faster than calling `IgorInfo` everytime. +threadsafe Function/S GetIgorInfo(variable selector) + + string key + + key = CA_IgorInfoKey(selector) + WAVE/T/Z result = CA_TryFetchingEntryFromCache(key, options = CA_OPTS_NO_DUPLICATE) + + if(!WaveExists(result)) + Make/FREE/T result = {IgorInfo(selector)} + CA_StoreEntryIntoCache(key, result, options = CA_OPTS_NO_DUPLICATE) + endif + + return result[0] +End + /// @brief Return the Igor Pro version string threadsafe Function/S GetIgorProVersion() - return StringByKey("IGORFILEVERSION", IgorInfo(3)) + return StringByKey("IGORFILEVERSION", GetIgorInfo(3)) End /// @brief Return the Igor Pro build version string @@ -2828,7 +2846,7 @@ End /// This allows to distinguish different builds from the same major/minor /// version. threadsafe Function/S GetIgorProBuildVersion() - return StringByKey("BUILD", IgorInfo(0)) + return StringByKey("BUILD", GetIgorInfo(0)) End /// @brief Return a unique symbolic path name From 780a89308045ce595e94aec3c0aa6e23b08a9822 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Mon, 8 Jan 2024 23:56:56 +0100 Subject: [PATCH 5/5] .github/workflows: Fix each commit CI job By fetching the full history and checking out the HEAD commit of the branch we fix it and using the action parameters is also less code. Broken since its introduction in c3e7dc3a (.github/workflows: Add job to compile test each commit, 2023-12-22). In addition we also need to pass --quit to git rebase as --abort resets HEAD which we don't want. Close #1968 --- .github/workflows/test-igor-rebase-exec-workflow.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-igor-rebase-exec-workflow.yml b/.github/workflows/test-igor-rebase-exec-workflow.yml index 1b890bfa37..b0c3b996e0 100644 --- a/.github/workflows/test-igor-rebase-exec-workflow.yml +++ b/.github/workflows/test-igor-rebase-exec-workflow.yml @@ -74,18 +74,14 @@ jobs: uses: actions/checkout@v3 with: submodules: recursive + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} - name: Initial repo config run: tools/initial-repo-config.sh - - name: Fetch latest changes for main - run: git fetch origin main - - name: Fetch latest changes of branch - run: git fetch origin $GITHUB_HEAD_REF - - name: Checking out branch - run: git checkout -B $GITHUB_HEAD_REF origin/$GITHUB_HEAD_REF - name: List of commits to operate on run: git log --pretty=ref origin/main.. - name: Cleanup earlier rebase invocations - run: git rebase --abort 2>/dev/null || true + run: git rebase --quit 2>/dev/null || true - name: Compile check each commit with ${{ inputs.experiment }} run: | git rebase --exec "git log --pretty=ref -n1" \