Files

196 lines
6.0 KiB
C++
Raw Permalink Normal View History

DDC: Switched to the async cache hierarchy and fully implemented the verify wrapper The async cache hierarchy: - Is required to add compression to the legacy cache by forwarding LegacyPut/LegacyGet to PutValue/GetValue. - Is always present in the graph, unlike the previous cache hierarchy, which will allow significant simplification of leaf cache stores. - Allows for the leaf cache store nodes to operate asynchronously without blocking a worker thread like the previous cache hierarchy. - Shifts from controlling cache behavior by speed class to controlling cache behavior by local/remote classification, which is a critical distinction for a cache like Zen that can identify as both local and remote. - Respects the local/remote and query/store flags in the cache policy. - Does not fully implement the partial record cache policy at this time. - Does not propagate records or values in GetChunks, which will be added in a future release. The verify wrapper was previously missing an implementation for the new cache interface. This version is more efficient than the previous because requests through the new cache interface can compare data without loading it from storage, and load it only when a mismatch has been detected, to dump it to disk. #jira UE-134381 #lockdown Mark.Lintott #preflight 61fc32ac0a50c2606f266388 #rb Zousar.Shaker #rnx #ROBOMERGE-AUTHOR: devin.doucette #ROBOMERGE-SOURCE: CL 18851861 in //UE5/Release-5.0/... via CL 18851943 via CL 18852169 #ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v910-18824042) [CL 18852184 by devin doucette in ue5-main branch]
2022-02-03 16:49:32 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
#include "Algo/Find.h"
#include "Algo/Transform.h"
#include "DerivedDataCachePrivate.h"
#include "DerivedDataCacheRecord.h"
#include "DerivedDataLegacyCacheStore.h"
#include "HAL/PlatformProcess.h"
#include "HAL/PlatformTime.h"
#include "ProfilingDebugging/CpuProfilerTrace.h"
DDC: Switched to the async cache hierarchy and fully implemented the verify wrapper The async cache hierarchy: - Is required to add compression to the legacy cache by forwarding LegacyPut/LegacyGet to PutValue/GetValue. - Is always present in the graph, unlike the previous cache hierarchy, which will allow significant simplification of leaf cache stores. - Allows for the leaf cache store nodes to operate asynchronously without blocking a worker thread like the previous cache hierarchy. - Shifts from controlling cache behavior by speed class to controlling cache behavior by local/remote classification, which is a critical distinction for a cache like Zen that can identify as both local and remote. - Respects the local/remote and query/store flags in the cache policy. - Does not fully implement the partial record cache policy at this time. - Does not propagate records or values in GetChunks, which will be added in a future release. The verify wrapper was previously missing an implementation for the new cache interface. This version is more efficient than the previous because requests through the new cache interface can compare data without loading it from storage, and load it only when a mismatch has been detected, to dump it to disk. #jira UE-134381 #lockdown Mark.Lintott #preflight 61fc32ac0a50c2606f266388 #rb Zousar.Shaker #rnx #ROBOMERGE-AUTHOR: devin.doucette #ROBOMERGE-SOURCE: CL 18851861 in //UE5/Release-5.0/... via CL 18851943 via CL 18852169 #ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v910-18824042) [CL 18852184 by devin doucette in ue5-main branch]
2022-02-03 16:49:32 -05:00
#include <atomic>
namespace UE::DerivedData
{
/**
* A cache store that increases the latency and reduces the throughput of another cache store.
* 1. Reproduce timings for a remote cache with a local cache, to reduce both network usage and measurement noise.
* 2. Reproduce HDD latency and throughput even when data is stored on SSD.
*/
class FCacheStoreThrottle final : public ILegacyCacheStore
{
public:
FCacheStoreThrottle(ILegacyCacheStore* InInnerCache, uint32 InLatencyMS, uint32 InMaxBytesPerSecond)
: InnerCache(InInnerCache)
, Latency(float(InLatencyMS) / 1000.0f)
, MaxBytesPerSecond(InMaxBytesPerSecond)
{
check(InnerCache);
}
~FCacheStoreThrottle() final
{
delete InnerCache;
}
DDC: Switched to the async cache hierarchy and fully implemented the verify wrapper The async cache hierarchy: - Is required to add compression to the legacy cache by forwarding LegacyPut/LegacyGet to PutValue/GetValue. - Is always present in the graph, unlike the previous cache hierarchy, which will allow significant simplification of leaf cache stores. - Allows for the leaf cache store nodes to operate asynchronously without blocking a worker thread like the previous cache hierarchy. - Shifts from controlling cache behavior by speed class to controlling cache behavior by local/remote classification, which is a critical distinction for a cache like Zen that can identify as both local and remote. - Respects the local/remote and query/store flags in the cache policy. - Does not fully implement the partial record cache policy at this time. - Does not propagate records or values in GetChunks, which will be added in a future release. The verify wrapper was previously missing an implementation for the new cache interface. This version is more efficient than the previous because requests through the new cache interface can compare data without loading it from storage, and load it only when a mismatch has been detected, to dump it to disk. #jira UE-134381 #lockdown Mark.Lintott #preflight 61fc32ac0a50c2606f266388 #rb Zousar.Shaker #rnx #ROBOMERGE-AUTHOR: devin.doucette #ROBOMERGE-SOURCE: CL 18851861 in //UE5/Release-5.0/... via CL 18851943 via CL 18852169 #ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v910-18824042) [CL 18852184 by devin doucette in ue5-main branch]
2022-02-03 16:49:32 -05:00
void Put(
const TConstArrayView<FCachePutRequest> Requests,
IRequestOwner& Owner,
FOnCachePutComplete&& OnComplete) final
{
struct FRecordSize
{
FCacheKey Key;
uint64 Size;
};
TArray<FRecordSize, TInlineAllocator<1>> RecordSizes;
RecordSizes.Reserve(Requests.Num());
Algo::Transform(Requests, RecordSizes, [](const FCachePutRequest& Request) -> FRecordSize
{
return {Request.Record.GetKey(), Private::GetCacheRecordCompressedSize(Request.Record)};
});
InnerCache->Put(Requests, Owner,
[this, RecordSizes = MoveTemp(RecordSizes), State = EnterThrottlingScope(), OnComplete = MoveTemp(OnComplete)](FCachePutResponse&& Response)
{
const FRecordSize* Size = Algo::FindBy(RecordSizes, Response.Key, &FRecordSize::Key);
CloseThrottlingScope(State, FThrottlingState(this, Size ? Size->Size : 0));
DDC: Enabled compression of legacy cache data - FileSystem, Http, Pak, S3 use the ValueWithLegacyFallback mode by default, which cause them to fall back to searching for uncompressed data if compressed data is not found. - FileSystem has been fixed to store up to 1 MiB of compressed data inline with the value package rather than separately in content-addressable storage. - Pak has been optimized to have GetChunks only load the required region of the requested value, rather than the whole value. - Pak has been changed to stop storing data inline in the record package, since it will end up in the same file anyway when stored separately. - Pak will upgrade the compressor and compression level when a compressed pak file is requested. Default cache compression uses Oodle Mermaid VeryFast and will upgrade to Oodle Kraken Optimal2. - Zen does not have compression enabled by default, pending deployment of a new version that stores compressed values to Horde Storage. - Added a missing request barrier when saving uncompressed data as compressed. Example reduction in file system cache size when cooking for Windows: - CitySample dropped from 66.5 GiB to 21.8 GiB. - Lyra dropped from 2.54 GiB to 672 MiB. - ShooterGame dropped from 1.21 GiB to 380 MiB. Example reduction in compressed pak file cache size when cooking for Windows: - CitySample dropped from 22.3 GiB to 18.5 GiB. - Lyra dropped from 691 MiB to 543 MiB. - ShooterGame dropped from 387 MiB to 313 MiB. #jira UE-134381 #preflight 620a703f583261b0a658e043, 620a6fb2803d9066e6805310, 620a733117632e948459b6af #lockdown Aurel.Cordonnier #rb Zousar.Shaker #ROBOMERGE-AUTHOR: devin.doucette #ROBOMERGE-SOURCE: CL 18983671 in //UE5/Release-5.0/... via CL 18983890 via CL 18984096 #ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589) [CL 18984126 by devin doucette in ue5-main branch]
2022-02-14 14:43:39 -05:00
OnComplete(MoveTemp(Response));
DDC: Switched to the async cache hierarchy and fully implemented the verify wrapper The async cache hierarchy: - Is required to add compression to the legacy cache by forwarding LegacyPut/LegacyGet to PutValue/GetValue. - Is always present in the graph, unlike the previous cache hierarchy, which will allow significant simplification of leaf cache stores. - Allows for the leaf cache store nodes to operate asynchronously without blocking a worker thread like the previous cache hierarchy. - Shifts from controlling cache behavior by speed class to controlling cache behavior by local/remote classification, which is a critical distinction for a cache like Zen that can identify as both local and remote. - Respects the local/remote and query/store flags in the cache policy. - Does not fully implement the partial record cache policy at this time. - Does not propagate records or values in GetChunks, which will be added in a future release. The verify wrapper was previously missing an implementation for the new cache interface. This version is more efficient than the previous because requests through the new cache interface can compare data without loading it from storage, and load it only when a mismatch has been detected, to dump it to disk. #jira UE-134381 #lockdown Mark.Lintott #preflight 61fc32ac0a50c2606f266388 #rb Zousar.Shaker #rnx #ROBOMERGE-AUTHOR: devin.doucette #ROBOMERGE-SOURCE: CL 18851861 in //UE5/Release-5.0/... via CL 18851943 via CL 18852169 #ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v910-18824042) [CL 18852184 by devin doucette in ue5-main branch]
2022-02-03 16:49:32 -05:00
});
}
void Get(
const TConstArrayView<FCacheGetRequest> Requests,
IRequestOwner& Owner,
FOnCacheGetComplete&& OnComplete) final
{
InnerCache->Get(Requests, Owner,
[this, State = EnterThrottlingScope(), OnComplete = MoveTemp(OnComplete)](FCacheGetResponse&& Response)
{
CloseThrottlingScope(State, FThrottlingState(this, Private::GetCacheRecordCompressedSize(Response.Record)));
DDC: Enabled compression of legacy cache data - FileSystem, Http, Pak, S3 use the ValueWithLegacyFallback mode by default, which cause them to fall back to searching for uncompressed data if compressed data is not found. - FileSystem has been fixed to store up to 1 MiB of compressed data inline with the value package rather than separately in content-addressable storage. - Pak has been optimized to have GetChunks only load the required region of the requested value, rather than the whole value. - Pak has been changed to stop storing data inline in the record package, since it will end up in the same file anyway when stored separately. - Pak will upgrade the compressor and compression level when a compressed pak file is requested. Default cache compression uses Oodle Mermaid VeryFast and will upgrade to Oodle Kraken Optimal2. - Zen does not have compression enabled by default, pending deployment of a new version that stores compressed values to Horde Storage. - Added a missing request barrier when saving uncompressed data as compressed. Example reduction in file system cache size when cooking for Windows: - CitySample dropped from 66.5 GiB to 21.8 GiB. - Lyra dropped from 2.54 GiB to 672 MiB. - ShooterGame dropped from 1.21 GiB to 380 MiB. Example reduction in compressed pak file cache size when cooking for Windows: - CitySample dropped from 22.3 GiB to 18.5 GiB. - Lyra dropped from 691 MiB to 543 MiB. - ShooterGame dropped from 387 MiB to 313 MiB. #jira UE-134381 #preflight 620a703f583261b0a658e043, 620a6fb2803d9066e6805310, 620a733117632e948459b6af #lockdown Aurel.Cordonnier #rb Zousar.Shaker #ROBOMERGE-AUTHOR: devin.doucette #ROBOMERGE-SOURCE: CL 18983671 in //UE5/Release-5.0/... via CL 18983890 via CL 18984096 #ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589) [CL 18984126 by devin doucette in ue5-main branch]
2022-02-14 14:43:39 -05:00
OnComplete(MoveTemp(Response));
DDC: Switched to the async cache hierarchy and fully implemented the verify wrapper The async cache hierarchy: - Is required to add compression to the legacy cache by forwarding LegacyPut/LegacyGet to PutValue/GetValue. - Is always present in the graph, unlike the previous cache hierarchy, which will allow significant simplification of leaf cache stores. - Allows for the leaf cache store nodes to operate asynchronously without blocking a worker thread like the previous cache hierarchy. - Shifts from controlling cache behavior by speed class to controlling cache behavior by local/remote classification, which is a critical distinction for a cache like Zen that can identify as both local and remote. - Respects the local/remote and query/store flags in the cache policy. - Does not fully implement the partial record cache policy at this time. - Does not propagate records or values in GetChunks, which will be added in a future release. The verify wrapper was previously missing an implementation for the new cache interface. This version is more efficient than the previous because requests through the new cache interface can compare data without loading it from storage, and load it only when a mismatch has been detected, to dump it to disk. #jira UE-134381 #lockdown Mark.Lintott #preflight 61fc32ac0a50c2606f266388 #rb Zousar.Shaker #rnx #ROBOMERGE-AUTHOR: devin.doucette #ROBOMERGE-SOURCE: CL 18851861 in //UE5/Release-5.0/... via CL 18851943 via CL 18852169 #ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v910-18824042) [CL 18852184 by devin doucette in ue5-main branch]
2022-02-03 16:49:32 -05:00
});
}
void PutValue(
const TConstArrayView<FCachePutValueRequest> Requests,
IRequestOwner& Owner,
FOnCachePutValueComplete&& OnComplete) final
{
struct FValueSize
{
FCacheKey Key;
uint64 Size;
};
TArray<FValueSize, TInlineAllocator<1>> ValueSizes;
ValueSizes.Reserve(Requests.Num());
Algo::Transform(Requests, ValueSizes, [](const FCachePutValueRequest& Request) -> FValueSize
{
return {Request.Key, Request.Value.GetData().GetCompressedSize()};
});
InnerCache->PutValue(Requests, Owner,
[this, ValueSizes = MoveTemp(ValueSizes), State = EnterThrottlingScope(), OnComplete = MoveTemp(OnComplete)](FCachePutValueResponse&& Response)
{
const FValueSize* Size = Algo::FindBy(ValueSizes, Response.Key, &FValueSize::Key);
CloseThrottlingScope(State, FThrottlingState(this, Size ? Size->Size : 0));
DDC: Enabled compression of legacy cache data - FileSystem, Http, Pak, S3 use the ValueWithLegacyFallback mode by default, which cause them to fall back to searching for uncompressed data if compressed data is not found. - FileSystem has been fixed to store up to 1 MiB of compressed data inline with the value package rather than separately in content-addressable storage. - Pak has been optimized to have GetChunks only load the required region of the requested value, rather than the whole value. - Pak has been changed to stop storing data inline in the record package, since it will end up in the same file anyway when stored separately. - Pak will upgrade the compressor and compression level when a compressed pak file is requested. Default cache compression uses Oodle Mermaid VeryFast and will upgrade to Oodle Kraken Optimal2. - Zen does not have compression enabled by default, pending deployment of a new version that stores compressed values to Horde Storage. - Added a missing request barrier when saving uncompressed data as compressed. Example reduction in file system cache size when cooking for Windows: - CitySample dropped from 66.5 GiB to 21.8 GiB. - Lyra dropped from 2.54 GiB to 672 MiB. - ShooterGame dropped from 1.21 GiB to 380 MiB. Example reduction in compressed pak file cache size when cooking for Windows: - CitySample dropped from 22.3 GiB to 18.5 GiB. - Lyra dropped from 691 MiB to 543 MiB. - ShooterGame dropped from 387 MiB to 313 MiB. #jira UE-134381 #preflight 620a703f583261b0a658e043, 620a6fb2803d9066e6805310, 620a733117632e948459b6af #lockdown Aurel.Cordonnier #rb Zousar.Shaker #ROBOMERGE-AUTHOR: devin.doucette #ROBOMERGE-SOURCE: CL 18983671 in //UE5/Release-5.0/... via CL 18983890 via CL 18984096 #ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589) [CL 18984126 by devin doucette in ue5-main branch]
2022-02-14 14:43:39 -05:00
OnComplete(MoveTemp(Response));
DDC: Switched to the async cache hierarchy and fully implemented the verify wrapper The async cache hierarchy: - Is required to add compression to the legacy cache by forwarding LegacyPut/LegacyGet to PutValue/GetValue. - Is always present in the graph, unlike the previous cache hierarchy, which will allow significant simplification of leaf cache stores. - Allows for the leaf cache store nodes to operate asynchronously without blocking a worker thread like the previous cache hierarchy. - Shifts from controlling cache behavior by speed class to controlling cache behavior by local/remote classification, which is a critical distinction for a cache like Zen that can identify as both local and remote. - Respects the local/remote and query/store flags in the cache policy. - Does not fully implement the partial record cache policy at this time. - Does not propagate records or values in GetChunks, which will be added in a future release. The verify wrapper was previously missing an implementation for the new cache interface. This version is more efficient than the previous because requests through the new cache interface can compare data without loading it from storage, and load it only when a mismatch has been detected, to dump it to disk. #jira UE-134381 #lockdown Mark.Lintott #preflight 61fc32ac0a50c2606f266388 #rb Zousar.Shaker #rnx #ROBOMERGE-AUTHOR: devin.doucette #ROBOMERGE-SOURCE: CL 18851861 in //UE5/Release-5.0/... via CL 18851943 via CL 18852169 #ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v910-18824042) [CL 18852184 by devin doucette in ue5-main branch]
2022-02-03 16:49:32 -05:00
});
}
void GetValue(
const TConstArrayView<FCacheGetValueRequest> Requests,
IRequestOwner& Owner,
FOnCacheGetValueComplete&& OnComplete) final
{
InnerCache->GetValue(Requests, Owner,
[this, State = EnterThrottlingScope(), OnComplete = MoveTemp(OnComplete)](FCacheGetValueResponse&& Response)
{
CloseThrottlingScope(State, FThrottlingState(this, Response.Value.GetData().GetCompressedSize()));
DDC: Enabled compression of legacy cache data - FileSystem, Http, Pak, S3 use the ValueWithLegacyFallback mode by default, which cause them to fall back to searching for uncompressed data if compressed data is not found. - FileSystem has been fixed to store up to 1 MiB of compressed data inline with the value package rather than separately in content-addressable storage. - Pak has been optimized to have GetChunks only load the required region of the requested value, rather than the whole value. - Pak has been changed to stop storing data inline in the record package, since it will end up in the same file anyway when stored separately. - Pak will upgrade the compressor and compression level when a compressed pak file is requested. Default cache compression uses Oodle Mermaid VeryFast and will upgrade to Oodle Kraken Optimal2. - Zen does not have compression enabled by default, pending deployment of a new version that stores compressed values to Horde Storage. - Added a missing request barrier when saving uncompressed data as compressed. Example reduction in file system cache size when cooking for Windows: - CitySample dropped from 66.5 GiB to 21.8 GiB. - Lyra dropped from 2.54 GiB to 672 MiB. - ShooterGame dropped from 1.21 GiB to 380 MiB. Example reduction in compressed pak file cache size when cooking for Windows: - CitySample dropped from 22.3 GiB to 18.5 GiB. - Lyra dropped from 691 MiB to 543 MiB. - ShooterGame dropped from 387 MiB to 313 MiB. #jira UE-134381 #preflight 620a703f583261b0a658e043, 620a6fb2803d9066e6805310, 620a733117632e948459b6af #lockdown Aurel.Cordonnier #rb Zousar.Shaker #ROBOMERGE-AUTHOR: devin.doucette #ROBOMERGE-SOURCE: CL 18983671 in //UE5/Release-5.0/... via CL 18983890 via CL 18984096 #ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589) [CL 18984126 by devin doucette in ue5-main branch]
2022-02-14 14:43:39 -05:00
OnComplete(MoveTemp(Response));
DDC: Switched to the async cache hierarchy and fully implemented the verify wrapper The async cache hierarchy: - Is required to add compression to the legacy cache by forwarding LegacyPut/LegacyGet to PutValue/GetValue. - Is always present in the graph, unlike the previous cache hierarchy, which will allow significant simplification of leaf cache stores. - Allows for the leaf cache store nodes to operate asynchronously without blocking a worker thread like the previous cache hierarchy. - Shifts from controlling cache behavior by speed class to controlling cache behavior by local/remote classification, which is a critical distinction for a cache like Zen that can identify as both local and remote. - Respects the local/remote and query/store flags in the cache policy. - Does not fully implement the partial record cache policy at this time. - Does not propagate records or values in GetChunks, which will be added in a future release. The verify wrapper was previously missing an implementation for the new cache interface. This version is more efficient than the previous because requests through the new cache interface can compare data without loading it from storage, and load it only when a mismatch has been detected, to dump it to disk. #jira UE-134381 #lockdown Mark.Lintott #preflight 61fc32ac0a50c2606f266388 #rb Zousar.Shaker #rnx #ROBOMERGE-AUTHOR: devin.doucette #ROBOMERGE-SOURCE: CL 18851861 in //UE5/Release-5.0/... via CL 18851943 via CL 18852169 #ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v910-18824042) [CL 18852184 by devin doucette in ue5-main branch]
2022-02-03 16:49:32 -05:00
});
}
void GetChunks(
const TConstArrayView<FCacheGetChunkRequest> Requests,
IRequestOwner& Owner,
FOnCacheGetChunkComplete&& OnComplete) final
{
InnerCache->GetChunks(Requests, Owner,
[this, State = EnterThrottlingScope(), OnComplete = MoveTemp(OnComplete)](FCacheGetChunkResponse&& Response)
{
CloseThrottlingScope(State, FThrottlingState(this, Response.RawData.GetSize()));
DDC: Enabled compression of legacy cache data - FileSystem, Http, Pak, S3 use the ValueWithLegacyFallback mode by default, which cause them to fall back to searching for uncompressed data if compressed data is not found. - FileSystem has been fixed to store up to 1 MiB of compressed data inline with the value package rather than separately in content-addressable storage. - Pak has been optimized to have GetChunks only load the required region of the requested value, rather than the whole value. - Pak has been changed to stop storing data inline in the record package, since it will end up in the same file anyway when stored separately. - Pak will upgrade the compressor and compression level when a compressed pak file is requested. Default cache compression uses Oodle Mermaid VeryFast and will upgrade to Oodle Kraken Optimal2. - Zen does not have compression enabled by default, pending deployment of a new version that stores compressed values to Horde Storage. - Added a missing request barrier when saving uncompressed data as compressed. Example reduction in file system cache size when cooking for Windows: - CitySample dropped from 66.5 GiB to 21.8 GiB. - Lyra dropped from 2.54 GiB to 672 MiB. - ShooterGame dropped from 1.21 GiB to 380 MiB. Example reduction in compressed pak file cache size when cooking for Windows: - CitySample dropped from 22.3 GiB to 18.5 GiB. - Lyra dropped from 691 MiB to 543 MiB. - ShooterGame dropped from 387 MiB to 313 MiB. #jira UE-134381 #preflight 620a703f583261b0a658e043, 620a6fb2803d9066e6805310, 620a733117632e948459b6af #lockdown Aurel.Cordonnier #rb Zousar.Shaker #ROBOMERGE-AUTHOR: devin.doucette #ROBOMERGE-SOURCE: CL 18983671 in //UE5/Release-5.0/... via CL 18983890 via CL 18984096 #ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589) [CL 18984126 by devin doucette in ue5-main branch]
2022-02-14 14:43:39 -05:00
OnComplete(MoveTemp(Response));
DDC: Switched to the async cache hierarchy and fully implemented the verify wrapper The async cache hierarchy: - Is required to add compression to the legacy cache by forwarding LegacyPut/LegacyGet to PutValue/GetValue. - Is always present in the graph, unlike the previous cache hierarchy, which will allow significant simplification of leaf cache stores. - Allows for the leaf cache store nodes to operate asynchronously without blocking a worker thread like the previous cache hierarchy. - Shifts from controlling cache behavior by speed class to controlling cache behavior by local/remote classification, which is a critical distinction for a cache like Zen that can identify as both local and remote. - Respects the local/remote and query/store flags in the cache policy. - Does not fully implement the partial record cache policy at this time. - Does not propagate records or values in GetChunks, which will be added in a future release. The verify wrapper was previously missing an implementation for the new cache interface. This version is more efficient than the previous because requests through the new cache interface can compare data without loading it from storage, and load it only when a mismatch has been detected, to dump it to disk. #jira UE-134381 #lockdown Mark.Lintott #preflight 61fc32ac0a50c2606f266388 #rb Zousar.Shaker #rnx #ROBOMERGE-AUTHOR: devin.doucette #ROBOMERGE-SOURCE: CL 18851861 in //UE5/Release-5.0/... via CL 18851943 via CL 18852169 #ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v910-18824042) [CL 18852184 by devin doucette in ue5-main branch]
2022-02-03 16:49:32 -05:00
});
}
void LegacyStats(FDerivedDataCacheStatsNode& OutNode) final
{
InnerCache->LegacyStats(OutNode);
}
bool LegacyDebugOptions(FBackendDebugOptions& Options) final
{
return InnerCache->LegacyDebugOptions(Options);
}
private:
struct FThrottlingState
{
double Time;
uint64 TotalBytesTransferred;
explicit FThrottlingState(FCacheStoreThrottle* ThrottleWrapper)
: Time(FPlatformTime::Seconds())
, TotalBytesTransferred(ThrottleWrapper->TotalBytesTransferred.load(std::memory_order_relaxed))
{
}
explicit FThrottlingState(FCacheStoreThrottle* ThrottleWrapper, uint64 BytesTransferred)
: Time(FPlatformTime::Seconds())
, TotalBytesTransferred(ThrottleWrapper->TotalBytesTransferred.fetch_add(BytesTransferred, std::memory_order_relaxed) + BytesTransferred)
{
}
};
FThrottlingState EnterThrottlingScope()
{
if (Latency > 0)
{
TRACE_CPUPROFILER_EVENT_SCOPE(ThrottlingLatency);
FPlatformProcess::Sleep(Latency);
}
return FThrottlingState(this);
}
void CloseThrottlingScope(FThrottlingState PreviousState, FThrottlingState CurrentState)
{
if (MaxBytesPerSecond)
{
// Take into account any other transfer that might have happened during that time from any other thread so we have a global limit
const double ExpectedTime = double(CurrentState.TotalBytesTransferred - PreviousState.TotalBytesTransferred) / MaxBytesPerSecond;
const double ActualTime = CurrentState.Time - PreviousState.Time;
if (ExpectedTime > ActualTime)
{
TRACE_CPUPROFILER_EVENT_SCOPE(ThrottlingBandwidth);
FPlatformProcess::Sleep(float(ExpectedTime - ActualTime));
DDC: Switched to the async cache hierarchy and fully implemented the verify wrapper The async cache hierarchy: - Is required to add compression to the legacy cache by forwarding LegacyPut/LegacyGet to PutValue/GetValue. - Is always present in the graph, unlike the previous cache hierarchy, which will allow significant simplification of leaf cache stores. - Allows for the leaf cache store nodes to operate asynchronously without blocking a worker thread like the previous cache hierarchy. - Shifts from controlling cache behavior by speed class to controlling cache behavior by local/remote classification, which is a critical distinction for a cache like Zen that can identify as both local and remote. - Respects the local/remote and query/store flags in the cache policy. - Does not fully implement the partial record cache policy at this time. - Does not propagate records or values in GetChunks, which will be added in a future release. The verify wrapper was previously missing an implementation for the new cache interface. This version is more efficient than the previous because requests through the new cache interface can compare data without loading it from storage, and load it only when a mismatch has been detected, to dump it to disk. #jira UE-134381 #lockdown Mark.Lintott #preflight 61fc32ac0a50c2606f266388 #rb Zousar.Shaker #rnx #ROBOMERGE-AUTHOR: devin.doucette #ROBOMERGE-SOURCE: CL 18851861 in //UE5/Release-5.0/... via CL 18851943 via CL 18852169 #ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v910-18824042) [CL 18852184 by devin doucette in ue5-main branch]
2022-02-03 16:49:32 -05:00
}
}
}
/** Backend to use for storage, my responsibilities are about throttling **/
ILegacyCacheStore* InnerCache;
float Latency;
uint32 MaxBytesPerSecond;
std::atomic<uint64> TotalBytesTransferred{0};
};
ILegacyCacheStore* CreateCacheStoreThrottle(ILegacyCacheStore* InnerCache, uint32 LatencyMS, uint32 MaxBytesPerSecond)
{
return new FCacheStoreThrottle(InnerCache, LatencyMS, MaxBytesPerSecond);
}
} // UE::DerivedData