Add more profile events to assets data loading

This commit is contained in:
Wojtek Figat
2021-05-14 13:00:03 +02:00
parent 401bd1c125
commit fbb9fa065a
3 changed files with 11 additions and 2 deletions

View File

@@ -165,7 +165,7 @@ bool ContentLoadingManagerService::Init()
// Calculate amount of loading threads to use
const CPUInfo cpuInfo = Platform::GetCPUInfo();
const int32 count = static_cast<int32>(Math::Clamp(LOADING_THREAD_PER_PHYSICAL_CORE * cpuInfo.ProcessorCoreCount, 1.0f, 4.0f));
const int32 count = Math::Clamp(static_cast<int32>(LOADING_THREAD_PER_PHYSICAL_CORE * (float)cpuInfo.ProcessorCoreCount), 1, 6);
LOG(Info, "Creating {0} content loading threads...", count);
// Create loading threads

View File

@@ -53,6 +53,9 @@ protected:
AssetReference<BinaryAsset> ref = _asset.Get();
if (ref == nullptr)
return Result::MissingReferences;
#if TRACY_ENABLE
const StringView name(ref->GetPath());
#endif
// Load chunks
for (int32 i = 0; i < ASSET_FILE_DATA_CHUNKS; i++)
@@ -62,11 +65,14 @@ protected:
const auto chunk = ref->GetChunk(i);
if (chunk != nullptr)
{
// Check for cancel
if (IsCancelRequested())
return Result::Ok;
// Load it
#if TRACY_ENABLE
ZoneScoped;
ZoneName(*name, name.Length());
#endif
if (ref->Storage->LoadAssetChunk(chunk))
{
LOG(Warning, "Cannot load asset \'{0}\' chunk {1}.", ref->ToString(), i);

View File

@@ -7,6 +7,7 @@
#include "Engine/Core/Log.h"
#include "Engine/Core/Types/TimeSpan.h"
#include "Engine/Platform/File.h"
#include "Engine/Profiler/ProfilerCPU.h"
#include "Engine/Serialization/FileWriteStream.h"
#if USE_EDITOR
#include "Engine/Serialization/JsonWriter.h"
@@ -628,6 +629,7 @@ bool FlaxStorage::LoadAssetChunk(FlaxChunk* chunk)
stream->ReadBytes(tmpBuf.Get(), size);
// Decompress data
PROFILE_CPU_NAMED("DecompressLZ4");
chunk->Data.Allocate(originalSize);
const int32 res = LZ4_decompress_safe((const char*)tmpBuf.Get(), chunk->Data.Get<char>(), size, originalSize);
if (res <= 0)
@@ -828,6 +830,7 @@ bool FlaxStorage::Create(WriteStream* stream, const AssetInitData* data, int32 d
const FlaxChunk* chunk = chunks[i];
if (chunk->Flags & FlaxChunkFlags::CompressedLZ4)
{
PROFILE_CPU_NAMED("CompressLZ4");
const int32 srcSize = chunk->Data.Length();
const int32 maxSize = LZ4_compressBound(srcSize);
auto& chunkCompressed = compressedChunks[i];