Deep hot-path optimizations: zero-allocation steady-state draw path#489
Merged
Merged
Conversation
Five targeted micro-optimizations across rendering, ECS, and asset subsystems, each verified against the full 5867-test suite. 1. Utils/Hash.h: add TransparentStringHash + TransparentStringEqual (is_transparent, std::hash<string_view>-backed) for heterogeneous unordered_map lookup by string_view/const char*. 2. AssetPipeline::m_assets switches to transparent hashing. BindMesh / BindMaterial now accept std::string_view, eliminating a pair of std::string allocations per draw call in GraphicsEngine::ProcessDrawList. 3. GraphicsEngine::ProcessDrawList double-buffers via std::swap against a new persistent m_processingDrawList. Previously std::move dropped capacity and reserve() reallocated each frame; now zero heap activity on the draw-list management path in steady state. 4. SpriteAnimatorSystem: hoist clip->frames.size() out of the per-entity inner loop (four repeated size+cast probes collapse to one). 5. MaterialSystem::m_materials and m_textureCache adopt transparent hashing for the same reason as AssetPipeline::m_assets — internal lookups and future string_view callers no longer allocate. Deferred as out-of-scope: camera mutex->atomic (thread-model change), lock-free asset queue (rearchitecture), std::function->template callbacks (API churn), MaterialPropertyHandle LRU (no profiling evidence). All 5867 tests pass. Documented in .claude/knowledge/deep-optimizations-2026-04-17.md. https://claude.ai/code/session_01NJoVwD2TUCvaHoXJS6fkrR
Contributor
Code Coverage (GCC + lcov)Per-Subsystem Coverage
Total: 50.3% (27443/54580 lines) |
Contributor
❌ CI Error ReportFailed jobs: check-format, clang-tidy, linux-clang-Release, macos-Debug, macos-Release, windows-vs2022-Release Build Errors
Other errors (2)Full error output
|
| Test | Jobs |
|---|---|
| [18:51:20.032] [TID:3028] [WARN ] [Network ] RCON unknown command: nonexistent_cmd (DedicatedServer.cpp:573) | windows-vs2022-Release |
| [18:51:20.051] [TID:3028] [WARN ] [Network ] NetBuffer::ReadUint8 — buffer overrun at pos 1 (size=1) (NetworkBuffer.c... | windows-vs2022-Release |
| [18:51:20.074] [TID:3028] [WARN ] [AI ] BuildNavMeshWithRecast: empty geometry (RecastDetourBackend.cpp:35) | windows-vs2022-Release |
| [18:51:20.074] [TID:3028] [WARN ] [AI ] NavMeshBuilder: Recast build failed, falling back to triangle-soup builder (N... | windows-vs2022-Release |
| [18:51:20.075] [TID:3028] [WARN ] [AI ] NavMeshBuilder: Recast build failed, falling back to triangle-soup builder (N... | windows-vs2022-Release |
| [18:51:20.075] [TID:3028] [WARN ] [Audio ] XAudio2 backend requested but no AudioEngine provided, falling back to Nul... | windows-vs2022-Release |
| [ OK ] NullRHIDevice_ReinitializeAfterShutdown (0us, 5 asse[18:51:20.077] [TID:3028] [WARN ] [Graphics ] No graphics ... | windows-vs2022-Release |
| [18:51:20.077] [TID:3028] [WARN ] [Graphics ] No graphics backend available — falling back to NullRHIDevice (headless... | windows-vs2022-Release |
| [18:51:20.082] [TID:3028] [WARN ] [Editor ] Cannot host: userName is empty. (CollaborativeEditSession.cpp:454) | windows-vs2022-Release |
| [18:51:20.082] [TID:3028] [WARN ] [Editor ] Already connected. (CollaborativeEditSession.cpp:459) | windows-vs2022-Release |
| [18:51:20.085] [TID:3028] [WARN ] [Editor ] BroadcastEdit rejected: nodeId is empty. (CollaborativeEditSession.cpp:1108) | windows-vs2022-Release |
| [18:51:20.085] [TID:3028] [WARN ] [Editor ] BroadcastEdit rejected: sourceEditor is not set. (CollaborativeEditSessio... | windows-vs2022-Release |
| [18:51:20.086] [TID:3028] [WARN ] [Editor ] SetLocalSelection rejected: nodeId exceeds 255 chars (length=300). (Colla... | windows-vs2022-Release |
| [18:51:25.646] [TID:3028] [WARN ] [Network ] Connection rejected for pending client 5: server full (4/4) (NetworkConn... | windows-vs2022-Release |
| [18:51:25.647] [TID:3028] [WARN ] [Network ] Connection rejected for pending client 5: server full (4/4) (NetworkConn... | windows-vs2022-Release |
Compiler Warnings (6)
../../../ThirdParty/SDL2/src/joystick/hidapi/SDL_hidapi_steam.c:165:9: warning: 'printf' macro redefined [-Wmacro-redefined] [linux-clang-Release]
../SparkEngine/Source/Engine/Animation/BlendSpace.cpp:313:16: warning: variable 'validTriCount' set but not used [-Wunused-but-set-variable] [linux-clang-Release]
../SparkEngine/Source/Physics/PhysicsBodyImpl.cpp:270:23: warning: comparing floating point with == or != is unsafe [-Wfloat-equal] [linux-clang-Release]
../SparkEngine/Source/Physics/PhysicsSystem.cpp:401:12: warning: use of old-style cast [-Wold-style-cast] [linux-clang-Release]
../../Tests/TestReliableChannel.cpp:390:9: warning: variable 'retransmitCount' set but not used [-Wunused-but-set-variable] [linux-clang-Release]
../../Tests/TestSparkError.cpp:34:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result] [linux-clang-Release]
Updated: 2026-04-17T19:02:51Z — this comment is updated in-place, not duplicated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Five targeted micro-optimizations across rendering, ECS, and asset subsystems, each verified against the full 5867-test suite.
Utils/Hash.h: add TransparentStringHash + TransparentStringEqual (is_transparent, std::hash<string_view>-backed) for heterogeneous unordered_map lookup by string_view/const char*.
AssetPipeline::m_assets switches to transparent hashing. BindMesh / BindMaterial now accept std::string_view, eliminating a pair of std::string allocations per draw call in GraphicsEngine::ProcessDrawList.
GraphicsEngine::ProcessDrawList double-buffers via std::swap against a new persistent m_processingDrawList. Previously std::move dropped capacity and reserve() reallocated each frame; now zero heap activity on the draw-list management path in steady state.
SpriteAnimatorSystem: hoist clip->frames.size() out of the per-entity inner loop (four repeated size+cast probes collapse to one).
MaterialSystem::m_materials and m_textureCache adopt transparent hashing for the same reason as AssetPipeline::m_assets — internal lookups and future string_view callers no longer allocate.
Deferred as out-of-scope: camera mutex->atomic (thread-model change), lock-free asset queue (rearchitecture), std::function->template callbacks (API churn), MaterialPropertyHandle LRU (no profiling evidence).
All 5867 tests pass. Documented in .claude/knowledge/deep-optimizations-2026-04-17.md.
https://claude.ai/code/session_01NJoVwD2TUCvaHoXJS6fkrR