Files
UnrealEngineUWP/Engine/Source/Developer/DerivedDataCache/Private/DerivedDataCacheStore.h
devin doucette 2800210897 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

133 lines
4.8 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "DerivedDataCache.h"
namespace UE::DerivedData { class ILegacyCacheStore; }
namespace UE::DerivedData { enum class EStatus : uint8; }
namespace UE::DerivedData
{
/**
* Interface to a store of cache records and cache values.
*
* Functions on this interface may be called from any thread.
*/
class ICacheStore
{
public:
virtual ~ICacheStore() = default;
/**
* Asynchronous request to put records in the cache.
*
* Behavior must match the cache record policy in each request. A few of those requirements:
* - Store with Query is expected *not* to overwrite an existing record.
* - Store without Query is permitted to overwrite an existing record.
* - Response must be Error if any value has unrecoverable missing data, unless the policy has PartialRecord.
*
* @param Requests Requests with the cache records to store. Records must have a key.
* @param Owner The owner to execute the request within. See IRequestOwner.
* @param OnComplete A callback invoked for every request as it completes or is canceled.
*/
virtual void Put(
TConstArrayView<FCachePutRequest> Requests,
IRequestOwner& Owner,
FOnCachePutComplete&& OnComplete) = 0;
/**
* Asynchronous request to get records from the cache.
*
* Behavior must match the cache record policy in each request. A few of those requirements:
* - Data is required if the value policy has Query.
* - Data must not be in the response if the value policy has SkipData.
* - Response must contain values and available data if the record policy has PartialRecord.
* - Response must be Error if any required data is missing, even if the record policy has PartialRecord.
*
* @param Requests Requests with the keys of the cache records to fetch.
* @param Owner The owner to execute the request within. See IRequestOwner.
* @param OnComplete A callback invoked for every request as it completes or is canceled.
*/
virtual void Get(
TConstArrayView<FCacheGetRequest> Requests,
IRequestOwner& Owner,
FOnCacheGetComplete&& OnComplete) = 0;
/**
* Asynchronous request to put values in the cache.
*
* @param Requests Requests with the cache values to store. Requests must have a key.
* @param Owner The owner to execute the request within. See IRequestOwner.
* @param OnComplete A callback invoked for every request as it completes or is canceled.
*/
virtual void PutValue(
TConstArrayView<FCachePutValueRequest> Requests,
IRequestOwner& Owner,
FOnCachePutValueComplete&& OnComplete) = 0;
/**
* Asynchronous request to get values from the cache.
*
* @param Requests Requests with the keys of the cache values to fetch.
* @param Owner The owner to execute the request within. See IRequestOwner.
* @param OnComplete A callback invoked for every request as it completes or is canceled.
*/
virtual void GetValue(
TConstArrayView<FCacheGetValueRequest> Requests,
IRequestOwner& Owner,
FOnCacheGetValueComplete&& OnComplete) = 0;
/**
* Asynchronous request to get chunks, which are subsets of values, from records or values.
*
* @param Requests Requests with the key, ID, offset, and size of each chunk to fetch.
* @param Owner The owner to execute the request within. See IRequestOwner.
* @param OnComplete A callback invoked for every request as it completes or is canceled.
*/
virtual void GetChunks(
TConstArrayView<FCacheGetChunkRequest> Requests,
IRequestOwner& Owner,
FOnCacheGetChunkComplete&& OnComplete) = 0;
};
enum class ECacheStoreFlags : uint32
{
None = 0,
/** Accepts requests with a policy of QueryLocal or StoreLocal. Needs matching Query/Store flag. */
Local = 1 << 0,
/** Accepts requests with a policy of QueryRemote or StoreRemote. Needs matching Query/Store flag.*/
Remote = 1 << 1,
/** Accepts requests with a policy of QueryLocal or QueryRemote. Needs matching Local/Remote flag. */
Query = 1 << 2,
/** Accepts requests with a policy of StoreLocal or StoreRemote. Needs matching Local/Remote flag. */
Store = 1 << 3,
/** Requests to store records or values contained by this cache store will not propagate any further. */
StopStore = 1 << 4,
};
ENUM_CLASS_FLAGS(ECacheStoreFlags);
class ICacheStoreOwner
{
public:
virtual void Add(ILegacyCacheStore* CacheStore, ECacheStoreFlags Flags) = 0;
virtual void SetFlags(ILegacyCacheStore* CacheStore, ECacheStoreFlags Flags) = 0;
virtual void RemoveNotSafe(ILegacyCacheStore* CacheStore) = 0;
};
template <typename RequestRangeType, typename OnCompleteType>
inline void CompleteWithStatus(RequestRangeType&& Requests, OnCompleteType&& OnComplete, EStatus Status)
{
for (const auto& Request : Requests)
{
OnComplete(Request.MakeResponse(Status));
}
}
} // UE::DerivedData