Files
UnrealEngineUWP/Engine/Source/Developer/DerivedDataCache/Private/DerivedDataBackendVerifyWrapper.h
Andrew Grant a572d8e23f Copying //UE4/Orion-Staging to //UE4/Main (Origin //Orion/Dev-General @ 2870388)
#lockdown Nick.Penwarden

==========================
MAJOR FEATURES + CHANGES
==========================

Change 2870336 on 2016/02/17 by Marc.Audy

	Continued splitting up Orion Build
	* Restructure from platform based MakeBuild steps in to a PS4, Server, and Windows Client MakeBuild
	* Cook server data only once for both Windows and Linux (windows reuses Linux server data)
	* Split compilation of Win64 Client and Server such that MakeBuild_Server only builds Server and MakeBuild_WindowsClient only builds Client
	#jira UEB-580
	#rb Ben.Marsh
	#tests Preflight and generated Windows Client and Server work to play game

Change 2870026 on 2016/02/17 by Wes.Hunt

	Don't allow array shrinking when removing the corruption wrapper trailer.
	#rb none
	Updating CIS Counter

Change 2869725 on 2016/02/17 by Dmitry.Rekman

	More analytics and QoS stats added for 0.19.

	#rb none
	#tests Ran Windows client and Linux server on compatible content.

Change 2869705 on 2016/02/16 by Ryan.Gerleve

	Fix replicated properties and call RepNotifies of startup actors when scrubbing in replays.
	This is the engine support for fixing OR-6817, towers not respawning when rewinding replays.

	#rb john.pollard
	#tests golden path, replays, ps4 nomcp

Change 2869644 on 2016/02/16 by Jason.Bestimt

	#ORION_DEV - Merge MAIN (0.18) at CL# 2869635

	#Tests:none
	#RB:none

Change 2869586 on 2016/02/16 by Marcus.Wassmer

	Fix texturestreaming RHI flushes.
	#rb none
	#test goldenpath
	#codereview Gil.Gribb

Change 2869279 on 2016/02/16 by Lukasz.Furman

	fixed minion hit reaction directions
	#orion OR-13953
	#rb Mieszko.Zielinski
	#tests PIE: hit minions with various abilities from different angles, checked velocity of death particles when killed by abilities and towers
	#codereview Dan.Youhon

Change 2869277 on 2016/02/16 by Wes.Hunt

	During cook, when a package is not ready to save, actually early out of the saving code. Saves somewhere in the 130s to 200s range for cooks.
	#rb daniel.lamb
	#tests local windows cooks, preflight PS4 cooks

Change 2869132 on 2016/02/16 by Mieszko.Zielinski

	Added a function to AISenseConfig allowing native-code MaxAge configuration #UE4

	#rb Lukasz.Furman
	#test none required

Change 2868981 on 2016/02/16 by Wes.Hunt

	remove -LogCookStats cmdline check, always log cook stats. -SendCookAnalytics flag is still used.
	This was requested by NickP.
	#rb none
	#tests local windows cooks

Change 2868975 on 2016/02/16 by Wes.Hunt

	Don't submit DDC usage stats for zero-sized events.
	#rb none
	#tests local windows cook

Change 2868956 on 2016/02/16 by Jason.Bestimt

	#ORION_DEV - Merge MAIN (0.18) at CL# 2868926

	#RB:none
	#Tests:none

Change 2868889 on 2016/02/16 by Max.Chen

	Sequencer: Only allow transport control binding when editing level editor sequencers.

	#rb none
	#tests none

Change 2868663 on 2016/02/16 by David.Ratti

	downgrade warning to display

	#rb none
	#tests compile

Change 2868624 on 2016/02/16 by Marcus.Wassmer

	Re-Enable Defrag validation for devgeneral
	#rb none
	#test none

Change 2868493 on 2016/02/16 by Benn.Gallagher

	Added a few more stats to morph target updates to try and narrow down hitches
	#rb Bruce.Nesbit
	#tests pie, -game Win64

Change 2868445 on 2016/02/16 by Dmitry.Rekman

	Linux: report crashes due to stack overflow (OR-14519).

	- Reserve memory for alternative stack for signal handlers. Adds about 128KB memory per thread.
	- Force process spawning to use vfork() when no pipes are needed.
	- Ignore all signals except explicitly handled.
	- Prevent signals from being raised while another one is handled.
	- Added "debug threadrecurse" and "debug threadstackoverflow" to test that.

[CL 2873763 by Andrew Grant in Main branch]
2016-02-19 12:03:17 -05:00

138 lines
4.0 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#pragma once
/**
* FDerivedDataBackendVerifyWrapper, a wrapper for derived data that verifies the cache is bit-wise identical by failing all gets and verifying the puts
**/
class FDerivedDataBackendVerifyWrapper : public FDerivedDataBackendInterface
{
public:
/**
* Constructor
*
* @param InInnerBackend Backend to use for storage, my responsibilities are about async puts
* @param InbFixProblems if true, fix any problems found
*/
FDerivedDataBackendVerifyWrapper(FDerivedDataBackendInterface* InInnerBackend, bool InbFixProblems)
: bFixProblems(InbFixProblems)
, InnerBackend(InInnerBackend)
{
check(InnerBackend);
}
virtual bool IsWritable() override
{
return true;
}
virtual bool CachedDataProbablyExists(const TCHAR* CacheKey) override
{
COOK_STAT(auto Timer = UsageStats.TimeProbablyExists());
FScopeLock ScopeLock(&SynchronizationObject);
if (AlreadyTested.Contains(FString(CacheKey)))
{
COOK_STAT(Timer.AddHit(0));
return true;
}
return false;
}
virtual bool GetCachedData(const TCHAR* CacheKey, TArray<uint8>& OutData) override
{
COOK_STAT(auto Timer = UsageStats.TimeGet());
bool bAlreadyTested = false;
{
FScopeLock ScopeLock(&SynchronizationObject);
if (AlreadyTested.Contains(FString(CacheKey)))
{
bAlreadyTested = true;
}
}
if (bAlreadyTested)
{
bool bResult = InnerBackend->GetCachedData(CacheKey, OutData);
if (bResult)
{
COOK_STAT(Timer.AddHit(OutData.Num()));
}
return bResult;
}
return false;
}
virtual void PutCachedData(const TCHAR* CacheKey, TArray<uint8>& InData, bool bPutEvenIfExists) override
{
COOK_STAT(auto Timer = UsageStats.TimePut());
bool bAlreadyTested = false;
{
FScopeLock ScopeLock(&SynchronizationObject);
if (AlreadyTested.Contains(FString(CacheKey)))
{
bAlreadyTested = true;
}
else
{
AlreadyTested.Add(FString(CacheKey));
}
}
if (!bAlreadyTested)
{
COOK_STAT(Timer.AddHit(InData.Num()));
TArray<uint8> OutData;
bool bSuccess = InnerBackend->GetCachedData(CacheKey, OutData);
if (bSuccess)
{
if (OutData != InData)
{
UE_LOG(LogDerivedDataCache, Error, TEXT("Verify: Cached data differs from newly generated data %s."), CacheKey);
FString Cache = FString(FPaths::GameSavedDir()) / TEXT("VerifyDDC") / CacheKey + TEXT(".fromcache");
FFileHelper::SaveArrayToFile(OutData, *Cache);
FString Verify = FString(FPaths::GameSavedDir()) / TEXT("VerifyDDC") / CacheKey + TEXT(".verify");;
FFileHelper::SaveArrayToFile(InData, *Verify);
if (bFixProblems)
{
UE_LOG(LogDerivedDataCache, Display, TEXT("Verify: Wrote newly generated data to the cache."), CacheKey);
InnerBackend->PutCachedData(CacheKey, InData, true);
}
}
else
{
UE_LOG(LogDerivedDataCache, Log, TEXT("Verify: Cached data exists and matched %s."), CacheKey);
}
}
else
{
UE_LOG(LogDerivedDataCache, Warning, TEXT("Verify: Cached data didn't exist %s."), CacheKey);
InnerBackend->PutCachedData(CacheKey, InData, bPutEvenIfExists);
}
}
}
virtual void RemoveCachedData(const TCHAR* CacheKey, bool bTransient) override
{
InnerBackend->RemoveCachedData(CacheKey, bTransient);
}
virtual void GatherUsageStats(TMap<FString, FDerivedDataCacheUsageStats>& UsageStatsMap, FString&& GraphPath) override
{
COOK_STAT(
{
UsageStatsMap.Add(GraphPath + TEXT(": VerifyWrapper"), UsageStats);
if (InnerBackend)
{
InnerBackend->GatherUsageStats(UsageStatsMap, GraphPath + TEXT(". 0"));
}
});
}
private:
FDerivedDataCacheUsageStats UsageStats;
/** If problems are encountered, do we fix them? */
bool bFixProblems;
/** Object used for synchronization via a scoped lock */
FCriticalSection SynchronizationObject;
/** Set of cache keys we already tested **/
TSet<FString> AlreadyTested;
/** Backend to service the actual requests */
FDerivedDataBackendInterface* InnerBackend;
};