Skip to content

Commit

Permalink
Fix performance issue with the diff of assets
Browse files Browse the repository at this point in the history
Rename RunDumpToFile() to RunGetFile()
Remove its first parameter InPathToPlasticBinary
Make it call "getfile" on the background shell instead of executing a new dedicated cm process
  • Loading branch information
SRombauts committed Apr 6, 2023
1 parent 64df305 commit f1e6e0d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "PlasticSourceControlRevision.h"
#include "PlasticSourceControlModule.h"
#include "PlasticSourceControlProvider.h"
#include "PlasticSourceControlState.h"
#include "PlasticSourceControlUtils.h"
#include "SPlasticSourceControlSettings.h"
Expand Down Expand Up @@ -52,8 +51,6 @@ bool FPlasticSourceControlRevision::Get(FString& InOutFilename, EConcurrency::Ty
}
else if (State)
{
const FString& PathToPlasticBinary = FPlasticSourceControlModule::Get().GetProvider().AccessSettings().GetBinaryPath();

FString RevisionSpecification;
if (ShelveId != ISourceControlState::INVALID_REVISION)
{
Expand All @@ -66,7 +63,7 @@ bool FPlasticSourceControlRevision::Get(FString& InOutFilename, EConcurrency::Ty
// Format the revision specification of the checked-in file, like rev:Content/BP.uasset#cs:12@repo@server:8087
RevisionSpecification = FString::Printf(TEXT("rev:%s#cs:%d@%s"), *Filename, ChangesetNumber, *State->RepSpec);
}
bCommandSuccessful = PlasticSourceControlUtils::RunDumpToFile(PathToPlasticBinary, RevisionSpecification, InOutFilename);
bCommandSuccessful = PlasticSourceControlUtils::RunGetFile(RevisionSpecification, InOutFilename);
}
else
{
Expand Down
27 changes: 8 additions & 19 deletions Source/PlasticSourceControl/Private/PlasticSourceControlUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#elif ENGINE_MAJOR_VERSION == 5
#include "HAL/PlatformFileManager.h"
#endif
#include "HAL/PlatformProcess.h"
#include "Misc/FileHelper.h"
#include "Misc/Paths.h"
#include "XmlParser.h"
Expand Down Expand Up @@ -1141,30 +1140,20 @@ bool RunUpdateStatus(const TArray<FString>& InFiles, const EStatusSearchType InS
return bResults;
}

// Run a Plastic "cat" command to dump the binary content of a revision into a file.
// cm cat revid:1230@rep:myrep@repserver:myserver:8084 --raw --file=Name124.tmp
bool RunDumpToFile(const FString& InPathToPlasticBinary, const FString& InRevSpec, const FString& InDumpFileName)
// Run a "getfile" command to dump the binary content of a revision into a file.
bool RunGetFile(const FString& InRevSpec, const FString& InDumpFileName)
{
TRACE_CPUPROFILER_EVENT_SCOPE(PlasticSourceControlUtils::RunDumpToFile);
TRACE_CPUPROFILER_EVENT_SCOPE(PlasticSourceControlUtils::RunGetFile);

int32 ReturnCode = 0;
FString Results;
FString Errors;

// start with the Plastic command itself, then add revspec and temp filename to dump
FString FullCommand = TEXT("cat \"");
FullCommand += InRevSpec;
FullCommand += TEXT("\" --raw --file=\"");
FullCommand += InDumpFileName;
FullCommand += TEXT("\"");

UE_LOG(LogSourceControl, Verbose, TEXT("RunDumpToFile: '%s %s'"), *InPathToPlasticBinary, *FullCommand);
const bool bResult = FPlatformProcess::ExecProcess(*InPathToPlasticBinary, *FullCommand, &ReturnCode, &Results, &Errors);
UE_LOG(LogSourceControl, Log, TEXT("RunDumpToFile: ExecProcess ReturnCode=%d Results='%s'"), ReturnCode, *Results);
if (!bResult || !Errors.IsEmpty())
{
UE_LOG(LogSourceControl, Error, TEXT("RunDumpToFile: ExecProcess ReturnCode=%d Errors='%s'"), ReturnCode, *Errors);
}
TArray<FString> Parameters;
Parameters.Add(InRevSpec);
Parameters.Add(TEXT("--raw"));
Parameters.Add(FString::Printf(TEXT("--file=\"%s\""), *InDumpFileName));
const bool bResult = PlasticSourceControlUtils::RunCommand(TEXT("getfile"), Parameters, TArray<FString>(), Results, Errors);

return bResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,11 @@ bool RunUpdateStatus(const TArray<FString>& InFiles, const EStatusSearchType InS
/**
* Run a Plastic "cat" command to dump the binary content of a revision into a file.
*
* @param InPathToPlasticBinary The path to the Plastic binary
* @param InRevSpec The revision specification to get
* @param InDumpFileName The temporary file to dump the revision
* @returns true if the command succeeded and returned no errors
*/
bool RunDumpToFile(const FString& InPathToPlasticBinary, const FString& InRevSpec, const FString& InDumpFileName);
bool RunGetFile(const FString& InRevSpec, const FString& InDumpFileName);

/**
* Run Plastic "history" and "log" commands and parse their XML results.
Expand Down

0 comments on commit f1e6e0d

Please sign in to comment.