Skip to content

Commit b0bf03f

Browse files
committed
fix: performance issues on menus, Studio open, other areas
* Throttle and cache RefreshUncommitted * Drop /SHELL in commands as much as possible (good for non-performance reasons too)
1 parent cc73a52 commit b0bf03f

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Deletion of files in locked environment is now suppressed (#302)
1414
- Failed to import file VS Code popup no longer shows up after overwriting file on server once (#264)
1515
- Don't automatically stage files added to source control (#303)
16+
- Performance improvements (#269, #315)
1617

1718
## [2.3.0] - 2023-12-06
1819

cls/SourceControl/Git/Change.cls

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,15 @@ ClassMethod IsUncommitted(Filename, ByRef ID) As %Boolean
7878
}
7979

8080
/// Goes through Uncommitted queue and removes any items of action 'edit' or 'add' which are ReadOnly or non-existent on the filesystem
81-
ClassMethod RefreshUncommitted(Display = 0, IncludeRevert = 0, Output gitFiles) As %Status
81+
ClassMethod RefreshUncommitted(Display = 0, IncludeRevert = 0, Output gitFiles, Force As %Boolean = 0) As %Status
8282
{
83+
if 'Force {
84+
// 10-second throttle on RefreshUncommitted
85+
if $zdatetime($ztimestamp,-2) - $Get(^IRIS.Temp.gitsourcecontrol("Refresh"),0) < 10 {
86+
merge gitFiles = ^IRIS.Temp.gitsourcecontrol("LastUncommitted")
87+
quit $$$OK
88+
}
89+
}
8390
kill gitFiles
8491

8592
// files from the uncommitted queue
@@ -124,6 +131,8 @@ ClassMethod RefreshUncommitted(Display = 0, IncludeRevert = 0, Output gitFiles)
124131
}
125132
set filename=$order(gitFiles(filename),1,details)
126133
}
134+
set ^IRIS.Temp.gitsourcecontrol("Refresh") = $zdatetime($ztimestamp,-2)
135+
merge ^IRIS.Temp.gitsourcecontrol("LastUncommitted") = gitFiles
127136
quit sc
128137
}
129138

cls/SourceControl/Git/Utils.cls

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ ClassMethod Revert(InternalName As %String) As %Status
285285
set filename = ..FullExternalName(.InternalName)
286286
do ..RunGitCommand("checkout", .errStream, .outStream, "--", filename)
287287
$$$QuitOnError(##class(SourceControl.Git.Change).RemoveUncommitted(filename,0,1))
288-
$$$QuitOnError(##class(SourceControl.Git.Change).RefreshUncommitted(0,1))
288+
$$$QuitOnError(##class(SourceControl.Git.Change).RefreshUncommitted(0,1,,1))
289289
$$$QuitOnError(..ImportItem(InternalName,1))
290290
quit $$$OK
291291
}
@@ -299,7 +299,7 @@ ClassMethod Commit(InternalName As %String, Message As %String = "example commit
299299
do ..RunGitWithArgs(.errStream, .outStream, "commit", "--author", author, "-m", Message, filename)
300300
do ..PrintStreams(outStream, outStream)
301301
$$$QuitOnError(##class(SourceControl.Git.Change).RemoveUncommitted(filename))
302-
$$$QuitOnError(##class(SourceControl.Git.Change).RefreshUncommitted())
302+
$$$QuitOnError(##class(SourceControl.Git.Change).RefreshUncommitted(,,,1))
303303
quit $$$OK
304304
}
305305

@@ -453,7 +453,7 @@ ClassMethod GenerateSSHKeyPair() As %Status
453453
do ##class(%File).CreateDirectoryChain(dir)
454454
set outLog = ##class(%Library.File).TempFilename()
455455
set errLog = ##class(%Library.File).TempFilename()
456-
do $zf(-100,"/SHELL /STDOUT="_$$$QUOTE(outLog)_" /STDERR="_$$$QUOTE(errLog),
456+
do $zf(-100,"/STDOUT="_$$$QUOTE(outLog)_" /STDERR="_$$$QUOTE(errLog),
457457
"ssh-keygen",
458458
"-t","ed25519",
459459
"-C",email,
@@ -1485,8 +1485,20 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
14851485
set errLog = ##class(%Library.File).TempFilename()
14861486

14871487
set command = $extract(..GitBinPath(),2,*-1)
1488-
// Need /SHELL on Linux to avoid permissions errors trying to use root's config
1489-
set returnCode = $zf(-100,"/SHELL /STDOUT="_$$$QUOTE(outLog)_" /STDERR="_$$$QUOTE(errLog)_$case(inFile, "":"", :" /STDIN="_$$$QUOTE(inFile)),command,newArgs...)
1488+
set baseArgs = "/STDOUT="_$$$QUOTE(outLog)_" /STDERR="_$$$QUOTE(errLog)_$case(inFile, "":"", :" /STDIN="_$$$QUOTE(inFile))
1489+
try {
1490+
// Inject instance manager directory as global git config home directory
1491+
// On Linux, this avoids trying to use /root/.config/git/attributes for global git config
1492+
set env("XDG_CONFIG_HOME") = ##class(%File).ManagerDirectory()
1493+
set returnCode = $zf(-100,"/ENV=env... "_baseArgs,command,newArgs...)
1494+
} catch e {
1495+
if $$$isWINDOWS {
1496+
set returnCode = $zf(-100,baseArgs,command,newArgs...)
1497+
} else {
1498+
// If can't inject XDG_CONFIG_HOME (older IRIS version), need /SHELL on Linux to avoid permissions errors trying to use root's config
1499+
set returnCode = $zf(-100,"/SHELL "_baseArgs,command,newArgs...)
1500+
}
1501+
}
14901502

14911503
set errStream = ##class(%Stream.FileCharacter).%OpenId(errLog,,.sc)
14921504
set outStream = ##class(%Stream.FileCharacter).%OpenId(outLog,,.sc)
@@ -1999,3 +2011,4 @@ ClassMethod ResetSourceControlClass()
19992011
}
20002012

20012013
}
2014+

0 commit comments

Comments
 (0)