You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
To better inform which sounds (and how many instances) we should cache, this CL adds several stats to track cache misses and utilzation of cached sounds. The majority of the tracking logic is encapsulated in the MetaSoundOperatorCacheStatTracker which handles updating active counts for each cached operator and emitting csv events. This change also adds the ability to write all active metasounds to the csv which can be situationally useful. It is disabled by default due to the overhead/csv bloat. #rnx #rb phil.popp #tests local replays, pie, horde RR [CL 34887862 by tyler staples in ue5-main branch]
94 lines
2.2 KiB
C++
94 lines
2.2 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
#pragma once
|
|
|
|
#include "CoreTypes.h"
|
|
#include "HAL/PlatformAtomics.h"
|
|
#include "ProfilingDebugging/CountersTrace.h"
|
|
#include "ProfilingDebugging/CsvProfiler.h"
|
|
#include "Stats/Stats.h"
|
|
#include "Templates/UniquePtr.h"
|
|
#include "UObject/NameTypes.h"
|
|
|
|
// todo: comments
|
|
|
|
namespace Metasound
|
|
{
|
|
#if COUNTERSTRACE_ENABLED
|
|
using CounterType = FCountersTrace::FCounterInt;
|
|
#else
|
|
using CounterType = FThreadSafeCounter64;
|
|
#endif
|
|
|
|
// forward
|
|
class FConcurrentInstanceCounter;
|
|
|
|
class FConcurrentInstanceCounterManager
|
|
{
|
|
public:
|
|
FConcurrentInstanceCounterManager(const FString InCategoryName);
|
|
|
|
void Increment(const FName& InstanceName);
|
|
void Decrement(const FName& IntsanceName);
|
|
|
|
int64 GetCountForName(const FName& InName);
|
|
int64 GetPeakCountForName(const FName& InName);
|
|
|
|
void VisitStats(TFunctionRef<void(const FName&, int64)> Visitor);
|
|
|
|
private:
|
|
struct FStats
|
|
{
|
|
public:
|
|
// ctor
|
|
#if COUNTERSTRACE_ENABLED
|
|
FStats(const FString& InName);
|
|
#else
|
|
FStats() = default;
|
|
#endif
|
|
|
|
void Increment();
|
|
void Decrement();
|
|
|
|
int64 GetCount() const;
|
|
int64 GetPeakCount() const;
|
|
|
|
private:
|
|
TUniquePtr<CounterType> TraceCounter;
|
|
int64 PeakCount;
|
|
|
|
}; // struct FStats
|
|
|
|
FStats& GetOrAddStats(const FName& InstanceName);
|
|
|
|
TMap<FName, FStats> StatsMap;
|
|
FCriticalSection MapCritSec;
|
|
FString CategoryName;
|
|
|
|
}; // class FConcurrentInstanceCounterManager
|
|
|
|
|
|
|
|
class FConcurrentInstanceCounter
|
|
{
|
|
public:
|
|
// ctor
|
|
FConcurrentInstanceCounter() = delete; // must init ManagerPtr
|
|
FConcurrentInstanceCounter(TSharedPtr<FConcurrentInstanceCounterManager> InCounterManager);
|
|
FConcurrentInstanceCounter(const FName& InName, TSharedPtr<FConcurrentInstanceCounterManager> InCounterManager);
|
|
FConcurrentInstanceCounter(const FString& InName, TSharedPtr<FConcurrentInstanceCounterManager> InCounterManager);
|
|
|
|
// dtor
|
|
virtual ~FConcurrentInstanceCounter();
|
|
|
|
// for non-RAII clients
|
|
void Init(const FName& InName);
|
|
void Init(const FString& InName);
|
|
|
|
private:
|
|
FConcurrentInstanceCounterManager& GetManagerChecked();
|
|
|
|
FName InstanceName;
|
|
TSharedPtr<FConcurrentInstanceCounterManager> ManagerPtr;
|
|
}; // class FConcurrentInstanceCounter
|
|
} // namespace Metasound
|