Files
Bigfoot/Bigfoot/Sources/Engine/Asset/AssetContainer.cpp
T
rboullardandClaude Sonnet 5 ae18a062b7
Bigfoot / Sonarqube (push) Skipped
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF) (push) Successful in 6m12s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON) (push) Successful in 5m49s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF) (push) Successful in 6m33s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON) (push) Successful in 6m50s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF) (push) Successful in 6m48s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF) (push) Failing after 32s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON) (push) Failing after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON) (push) Successful in 6m40s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON) (push) Successful in 15m18s
Bigfoot / Clang Format Checks (push) Failing after 10s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON) (push) Successful in 16m5s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF) (push) Successful in 16m28s
Add Sasquatch: mmap'd, load-only Game-mode asset backend, plus parallel batch loading
Introduces a dual-backend SerializationManager: Tool mode keeps reading/writing
BigFile over SQL as before, Game mode now reads a Sasquatch file instead - a
flattened, mmap'd counterpart to a BigFile produced ahead of time by
Sasquatch::WriteFrom or the new SasquatchPacker CLI tool. The backend is picked
at compile time via a new BIGFOOT_TOOL_MODE option (mirrors the existing
BIGFOOT_OPTIMIZED/BIGFOOT_NOT_OPTIMIZED pattern); SaveAsset only exists in Tool
mode, since a running game never writes back to its own asset pack.

Also adds SerializationManager::LoadAssets (Game-mode only): loads a batch of
UUIDs by decoding them across multiple threads instead of one at a time,
layered by HardReference depth so a reference target is always fully
registered before anything decodes a reference to it. This required making
HardReference/SoftReference resolution genuinely thread-safe (it mutates
ContainerHandle ref counts and AssetLibrary's UUID index/unreferenced-set from
inside Unpack()) via atomic ref counts and targeted mutexes, validated by
dedicated concurrency tests exercising real thread contention.

BigFile itself is faster too: prepared statements are now pooled per query
text instead of recompiled on every Request (pooled rather than cached-as-one
because LoadAsset recurses and a naive cache would corrupt an in-flight
statement), and PRAGMA mmap_size is enabled.

Benchmarked against real Asset<T> objects (AssetsForBenchmarking) through the
full Pack/Unpack/HardReference pipeline: Sasquatch's raw storage layer hits
~31 GiB/s (mmap ceiling), and the new parallel LoadAssets reaches ~18 GiB/s
end-to-end versus ~1.3 GiB/s for the existing sequential LoadAsset loop.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-22 17:43:21 +02:00

46 lines
1.2 KiB
C++

/*********************************************************************
* \file AssetContainer.cpp
*
* \author Romain BOULLARD
* \date August 2026
*********************************************************************/
#include <Engine/Asset/AssetContainer.hpp>
#include <Engine/Asset/AssetLibrary.hpp>
namespace Bigfoot
{
AssetContainerBase::Entry& AssetContainerBase::GetOrCreateEntry(const UUID& p_uuid)
{
const std::lock_guard lock {m_entryMutex};
auto [it, inserted] = m_uuidToEntry.try_emplace(p_uuid);
if (inserted)
{
it->second.m_handleSlotKey = m_handles.Insert();
if (m_owningLibrary != nullptr)
{
m_owningLibrary->RegisterUUID(p_uuid, this);
}
}
return it->second;
}
/****************************************************************************************/
void AssetContainerBase::Remove(const UUID& p_uuid)
{
if (Entry* entry = FindEntry(p_uuid); entry != nullptr && entry->m_handleSlotKey.Valid())
{
m_handles.Remove(entry->m_handleSlotKey);
m_uuidToEntry.erase(p_uuid);
if (m_owningLibrary != nullptr)
{
m_owningLibrary->UnregisterUUID(p_uuid);
}
}
}
} // namespace Bigfoot