Skip to content

Commit

Permalink
Merge pull request #1967 from AllenInstitute/bugfix/1967-make-igorinf…
Browse files Browse the repository at this point in the history
…o-faster

Make IgorInfo faster
  • Loading branch information
t-b authored Jan 11, 2024
2 parents 6c495f2 + 780a893 commit fd8c36a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 17 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/test-igor-rebase-exec-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
16 changes: 16 additions & 0 deletions Packages/MIES/MIES_Cache.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_CheckInstallation.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Function CHI_CheckInstallation()
CHI_InitInstallationState(state)

info = IgorInfo(0)
igorBuild = StringByKey("BUILD", info)
igorBuild = GetIgorProBuildVersion()

if(!isEmpty(igorBuild))
igorBuild = ", " + igorBuild
Expand Down
8 changes: 4 additions & 4 deletions Packages/MIES/MIES_GlobalStringAndVariableAccess.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,23 @@ 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

/// @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
Expand Down
28 changes: 23 additions & 5 deletions Packages/MIES/MIES_Utilities.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -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 "################################"
Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -2818,17 +2818,35 @@ 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
///
/// This allows to distinguish different builds from the same major/minor
/// version.
Function/S GetIgorProBuildVersion()
return StringByKey("BUILD", IgorInfo(0))
threadsafe Function/S GetIgorProBuildVersion()
return StringByKey("BUILD", GetIgorInfo(0))
End

/// @brief Return a unique symbolic path name
Expand Down

0 comments on commit fd8c36a

Please sign in to comment.