Bigfoot / Sonarqube (push) Skipped
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Failing after 28s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Failing after 17s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 27s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Failing after 39s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Failing after 24s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 1m0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 50s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Failing after 23s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Failing after 15s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 46s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 35s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 24s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Failing after 28s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Failing after 20s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 1m0s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 47s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Failing after 33s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Failing after 20s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 40s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 39s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Failing after 24s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Failing after 20s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 44s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 41s
Bigfoot / Clang Format Checks (push) Successful in 9s
331 lines
11 KiB
C++
331 lines
11 KiB
C++
/*********************************************************************
|
|
* \file BigFile.cpp
|
|
*
|
|
* \author Romain BOULLARD
|
|
* \date August 2026
|
|
*********************************************************************/
|
|
#include <Engine/BigFile/BigFile.hpp>
|
|
|
|
#include <System/File/File.hpp>
|
|
#include <System/UUID/UUID.hpp>
|
|
|
|
#include <EngineBenchmarks/BigFileInfo_generated.hpp>
|
|
|
|
#include <AssetsForBenchmarking/Asset/BenchmarkAsset.hpp>
|
|
#include <AssetsForBenchmarking/Asset/BenchmarkAssetReferred.hpp>
|
|
|
|
#include <EASTL/vector.h>
|
|
#include <benchmark/benchmark.h>
|
|
#include <effolkronium/random.hpp>
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
|
|
namespace Bigfoot
|
|
{
|
|
#ifdef BIGFOOT_TOOLMODE
|
|
using Random = effolkronium::random_static;
|
|
|
|
class BigFileFixture: public benchmark::Fixture
|
|
{
|
|
protected:
|
|
static constexpr std::uint32_t ASSET_COUNT = 20'000;
|
|
static constexpr std::size_t ASSET_PAYLOAD_SIZE = 256;
|
|
|
|
void SetUp(benchmark::State&) override
|
|
{
|
|
m_bigFile.Clear();
|
|
|
|
m_uuids.clear();
|
|
m_uuids.reserve(ASSET_COUNT);
|
|
|
|
eastl::vector<AssetMetadata> metadatas;
|
|
eastl::vector<eastl::vector<std::byte>> flatbuffers;
|
|
eastl::vector<eastl::vector<UUID>> hardReferences;
|
|
metadatas.reserve(ASSET_COUNT);
|
|
flatbuffers.reserve(ASSET_COUNT);
|
|
hardReferences.reserve(ASSET_COUNT);
|
|
|
|
for (std::uint32_t i = 0; i < ASSET_COUNT; ++i)
|
|
{
|
|
BenchmarkAsset asset;
|
|
asset.SetName(asset.GetHeader().uuid.ToString().c_str());
|
|
asset.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB});
|
|
for (std::uint32_t j = 0; j < 4; ++j)
|
|
{
|
|
BenchmarkAssetReferred assetReferred;
|
|
assetReferred.SetName(assetReferred.GetHeader().uuid.ToString().c_str());
|
|
|
|
asset.GetAsset().refs.emplace_back(assetReferred.GetHeader().uuid);
|
|
}
|
|
|
|
metadatas.push_back(AssetMetadata {.m_uuid = asset.GetHeader().uuid,
|
|
.m_name = asset.GetHeader().name,
|
|
.m_typeID = asset.GetHeader().type_id,
|
|
.m_typeName = asset.GetHeader().type_name});
|
|
const eastl::vector<std::byte> flatbuffer = asset.Pack();
|
|
flatbuffers.push_back(flatbuffer);
|
|
hardReferences.push_back(BenchmarkAsset::GetHardReferences(flatbuffer));
|
|
m_uuids.push_back(asset.GetHeader().uuid);
|
|
}
|
|
|
|
m_bigFile.SaveAssetFlatbuffers(metadatas, flatbuffers, hardReferences);
|
|
}
|
|
|
|
[[nodiscard]]
|
|
eastl::vector<UUID> RandomBatch(const std::size_t p_batchSize) const
|
|
{
|
|
eastl::vector<UUID> batch;
|
|
batch.reserve(p_batchSize);
|
|
for (std::size_t i = 0; i < p_batchSize; ++i)
|
|
{
|
|
batch.push_back(m_uuids[Random::get<std::size_t>(0, m_uuids.size() - 1)]);
|
|
}
|
|
|
|
return batch;
|
|
}
|
|
|
|
[[nodiscard]]
|
|
eastl::vector<eastl::vector<UUID>> RandomBatchPool(const std::size_t p_batchSize,
|
|
const std::size_t p_poolSize) const
|
|
{
|
|
eastl::vector<eastl::vector<UUID>> pool;
|
|
pool.reserve(p_poolSize);
|
|
for (std::size_t i = 0; i < p_poolSize; ++i)
|
|
{
|
|
pool.push_back(RandomBatch(p_batchSize));
|
|
}
|
|
|
|
return pool;
|
|
}
|
|
|
|
BigFile m_bigFile {File {BIGFILE_ENGINEBENCHMARKS_LOCATION}};
|
|
eastl::vector<UUID> m_uuids;
|
|
};
|
|
|
|
/****************************************************************************************/
|
|
|
|
BENCHMARK_DEFINE_F(BigFileFixture, GetAssetFlatbuffer)(benchmark::State& state)
|
|
{
|
|
std::int64_t bytesProcessed = 0;
|
|
|
|
for (auto _: state)
|
|
{
|
|
eastl::optional<eastl::vector<std::byte>> flatbuffer = m_bigFile.GetAssetFlatbuffer(
|
|
m_uuids[Random::get<std::size_t>(0, m_uuids.size() - 1)]);
|
|
benchmark::DoNotOptimize(flatbuffer);
|
|
|
|
if (flatbuffer.has_value())
|
|
{
|
|
bytesProcessed += static_cast<std::int64_t>(flatbuffer->size());
|
|
}
|
|
}
|
|
|
|
state.SetItemsProcessed(state.iterations());
|
|
state.SetBytesProcessed(bytesProcessed);
|
|
}
|
|
|
|
BENCHMARK_REGISTER_F(BigFileFixture, GetAssetFlatbuffer)->Name("BigFile/GetAssetFlatbuffer");
|
|
|
|
/****************************************************************************************/
|
|
|
|
BENCHMARK_DEFINE_F(BigFileFixture, GetAssetFlatbuffers)(benchmark::State& state)
|
|
{
|
|
const auto batchSize = static_cast<std::size_t>(state.range(0));
|
|
|
|
constexpr std::size_t BATCH_POOL_SIZE = 64;
|
|
const eastl::vector<eastl::vector<UUID>> batchPool = RandomBatchPool(batchSize, BATCH_POOL_SIZE);
|
|
|
|
std::int64_t bytesProcessed = 0;
|
|
std::size_t batchIndex = 0;
|
|
|
|
for (auto _: state)
|
|
{
|
|
eastl::vector<eastl::vector<std::byte>> flatbuffers = m_bigFile.GetAssetFlatbuffers(batchPool[batchIndex]);
|
|
benchmark::DoNotOptimize(flatbuffers);
|
|
|
|
for (const eastl::vector<std::byte>& flatbuffer: flatbuffers)
|
|
{
|
|
bytesProcessed += static_cast<std::int64_t>(flatbuffer.size());
|
|
}
|
|
|
|
batchIndex = (batchIndex + 1) % BATCH_POOL_SIZE;
|
|
}
|
|
|
|
state.SetItemsProcessed(state.iterations() * batchSize);
|
|
state.SetBytesProcessed(bytesProcessed);
|
|
}
|
|
|
|
BENCHMARK_REGISTER_F(BigFileFixture, GetAssetFlatbuffers)
|
|
->Name("BigFile/GetAssetFlatbuffers")
|
|
->Arg(1)
|
|
->Arg(8)
|
|
->Arg(64)
|
|
->Arg(512)
|
|
->Arg(4096);
|
|
|
|
/****************************************************************************************/
|
|
|
|
BENCHMARK_DEFINE_F(BigFileFixture, GetAssetMetadata)(benchmark::State& state)
|
|
{
|
|
for (auto _: state)
|
|
{
|
|
benchmark::DoNotOptimize(m_bigFile.GetAssetMetadata(m_uuids[Random::get<std::size_t>(0, m_uuids.size() - 1)]));
|
|
}
|
|
|
|
state.SetItemsProcessed(state.iterations());
|
|
}
|
|
|
|
BENCHMARK_REGISTER_F(BigFileFixture, GetAssetMetadata)->Name("BigFile/GetAssetMetadata");
|
|
|
|
/****************************************************************************************/
|
|
|
|
BENCHMARK_DEFINE_F(BigFileFixture, GetAssetMetadatas)(benchmark::State& state)
|
|
{
|
|
const auto batchSize = static_cast<std::size_t>(state.range(0));
|
|
|
|
constexpr std::size_t BATCH_POOL_SIZE = 64;
|
|
const eastl::vector<eastl::vector<UUID>> batchPool = RandomBatchPool(batchSize, BATCH_POOL_SIZE);
|
|
|
|
std::size_t batchIndex = 0;
|
|
for (auto _: state)
|
|
{
|
|
benchmark::DoNotOptimize(m_bigFile.GetAssetMetadatas(batchPool[batchIndex]));
|
|
batchIndex = (batchIndex + 1) % BATCH_POOL_SIZE;
|
|
}
|
|
|
|
state.SetItemsProcessed(state.iterations() * batchSize);
|
|
}
|
|
|
|
BENCHMARK_REGISTER_F(BigFileFixture, GetAssetMetadatas)
|
|
->Name("BigFile/GetAssetMetadatas")
|
|
->Arg(1)
|
|
->Arg(8)
|
|
->Arg(64)
|
|
->Arg(512)
|
|
->Arg(4096);
|
|
|
|
/****************************************************************************************/
|
|
|
|
BENCHMARK_DEFINE_F(BigFileFixture, GetAssetHardReferences)(benchmark::State& state)
|
|
{
|
|
for (auto _: state)
|
|
{
|
|
benchmark::DoNotOptimize(
|
|
m_bigFile.GetAssetHardReferences(m_uuids[Random::get<std::size_t>(0, m_uuids.size() - 1)]));
|
|
}
|
|
|
|
state.SetItemsProcessed(state.iterations());
|
|
}
|
|
|
|
BENCHMARK_REGISTER_F(BigFileFixture, GetAssetHardReferences)->Name("BigFile/GetAssetHardReferences");
|
|
|
|
/****************************************************************************************/
|
|
|
|
BENCHMARK_DEFINE_F(BigFileFixture, GetAssetsHardReferences)(benchmark::State& state)
|
|
{
|
|
const auto batchSize = static_cast<std::size_t>(state.range(0));
|
|
|
|
constexpr std::size_t BATCH_POOL_SIZE = 64;
|
|
const eastl::vector<eastl::vector<UUID>> batchPool = RandomBatchPool(batchSize, BATCH_POOL_SIZE);
|
|
|
|
std::size_t batchIndex = 0;
|
|
for (auto _: state)
|
|
{
|
|
benchmark::DoNotOptimize(m_bigFile.GetAssetsHardReferences(batchPool[batchIndex]));
|
|
batchIndex = (batchIndex + 1) % BATCH_POOL_SIZE;
|
|
}
|
|
|
|
state.SetItemsProcessed(state.iterations() * batchSize);
|
|
}
|
|
|
|
BENCHMARK_REGISTER_F(BigFileFixture, GetAssetsHardReferences)
|
|
->Name("BigFile/GetAssetsHardReferences")
|
|
->Arg(1)
|
|
->Arg(8)
|
|
->Arg(64)
|
|
->Arg(512)
|
|
->Arg(4096);
|
|
|
|
/****************************************************************************************/
|
|
|
|
BENCHMARK_DEFINE_F(BigFileFixture, SaveAssetFlatbuffer)(benchmark::State& state)
|
|
{
|
|
std::int64_t bytesProcessed = 0;
|
|
|
|
for (auto _: state)
|
|
{
|
|
state.PauseTiming();
|
|
BenchmarkAsset asset;
|
|
asset.SetName(asset.GetHeader().uuid.ToString().c_str());
|
|
asset.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB});
|
|
|
|
const AssetMetadata metadata {.m_uuid = asset.GetHeader().uuid,
|
|
.m_name = asset.GetHeader().name,
|
|
.m_typeID = asset.GetHeader().type_id,
|
|
.m_typeName = asset.GetHeader().type_name};
|
|
const eastl::vector<std::byte> flatbuffer = asset.Pack();
|
|
const eastl::vector<UUID> hardReferences = BenchmarkAsset::GetHardReferences(flatbuffer);
|
|
bytesProcessed += static_cast<std::int64_t>(flatbuffer.size());
|
|
state.ResumeTiming();
|
|
|
|
m_bigFile.SaveAssetFlatbuffer(metadata, flatbuffer, hardReferences);
|
|
}
|
|
|
|
state.SetItemsProcessed(state.iterations());
|
|
state.SetBytesProcessed(bytesProcessed);
|
|
}
|
|
|
|
BENCHMARK_REGISTER_F(BigFileFixture, SaveAssetFlatbuffer)->Name("BigFile/SaveAssetFlatbuffer");
|
|
|
|
/****************************************************************************************/
|
|
|
|
BENCHMARK_DEFINE_F(BigFileFixture, SaveAssetFlatbuffers)(benchmark::State& state)
|
|
{
|
|
const auto batchSize = static_cast<std::size_t>(state.range(0));
|
|
std::int64_t bytesProcessed = 0;
|
|
|
|
for (auto _: state)
|
|
{
|
|
state.PauseTiming();
|
|
eastl::vector<AssetMetadata> metadatas;
|
|
eastl::vector<eastl::vector<std::byte>> flatbuffers;
|
|
eastl::vector<eastl::vector<UUID>> hardReferences;
|
|
metadatas.reserve(batchSize);
|
|
flatbuffers.reserve(batchSize);
|
|
hardReferences.reserve(batchSize);
|
|
|
|
for (std::size_t i = 0; i < batchSize; ++i)
|
|
{
|
|
BenchmarkAsset asset;
|
|
asset.SetName(asset.GetHeader().uuid.ToString().c_str());
|
|
asset.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB});
|
|
|
|
metadatas.push_back(AssetMetadata {.m_uuid = asset.GetHeader().uuid,
|
|
.m_name = asset.GetHeader().name,
|
|
.m_typeID = asset.GetHeader().type_id,
|
|
.m_typeName = asset.GetHeader().type_name});
|
|
const eastl::vector<std::byte> flatbuffer = asset.Pack();
|
|
flatbuffers.push_back(flatbuffer);
|
|
hardReferences.push_back(BenchmarkAsset::GetHardReferences(flatbuffer));
|
|
bytesProcessed += static_cast<std::int64_t>(flatbuffer.size());
|
|
}
|
|
state.ResumeTiming();
|
|
|
|
m_bigFile.SaveAssetFlatbuffers(metadatas, flatbuffers, hardReferences);
|
|
}
|
|
|
|
state.SetItemsProcessed(state.iterations() * batchSize);
|
|
state.SetBytesProcessed(bytesProcessed);
|
|
}
|
|
|
|
BENCHMARK_REGISTER_F(BigFileFixture, SaveAssetFlatbuffers)
|
|
->Name("BigFile/SaveAssetFlatbuffers")
|
|
->Arg(1)
|
|
->Arg(8)
|
|
->Arg(64)
|
|
->Arg(512)
|
|
->Arg(4096);
|
|
#endif
|
|
} // namespace Bigfoot
|