Repository navigation
Codebase Bloat Audit
Audience: Programmers | Mixed
Thread Context: N/A (audit/reference)
Platform/Backend Scope: All platforms / all backends
A point-in-time audit of oversized files, dead code, orphaned systems, and structural duplication, measured against the anti-bloat thresholds in CLAUDE.md (~500 lines for .cpp, ~300 lines for .h, ~15 public methods per class). The original audit (March 2026) was run against an earlier, much larger set of monolithic files; most of its P0/P1 offenders have since been split or deleted. This page carries forward the methodology and reports a fresh largest-files scan as of 2026-06-08.
Thresholds are guidelines for when to pause and think, not hard limits — a clean 450-line .cpp is fine; a cryptic 200-line one is not. See the Readability Principle in CLAUDE.md.
| File | Lines |
|---|---|
Graphics/RHI/OpenGL/OpenGLDevice.cpp |
2,103 |
Graphics/RHI/Vulkan/VulkanDevice.cpp |
1,991 |
SparkEditor/Source/Panels/VisualScriptPanel.cpp |
1,773 |
SparkEditor/Source/Profiler/PerformanceProfiler.cpp |
1,609 |
Graphics/RHI/D3D12/D3D12Device.cpp |
1,593 |
SparkEditor/Source/Core/EditorTheme.cpp |
1,587 |
Graphics/PostProcessingPipeline.cpp |
1,538 |
Core/EngineSettings.cpp |
1,522 |
SparkEditor/Source/Core/EditorUI.cpp |
1,516 |
SparkEditor/Source/Panels/ProjectSettingsPanel.cpp |
1,501 |
Graphics/RHI/D3D11/D3D11Device.cpp |
1,481 |
Graphics/GraphicsEngineWindows.cpp |
1,481 |
SparkConsole/src/ConsoleApp.cpp |
1,407 |
SparkEditor/Source/Communication/CollaborativeEditSession.cpp |
1,373 |
SparkEditor/Source/Panels/InspectorComponentRenderers_Reflected.cpp |
1,362 |
Core/Lifecycle/GameplayLifecycleShared.cpp |
1,347 |
Utils/CrashHandler.cpp |
1,322 |
Core/SparkEngineLinux.cpp |
1,296 |
SparkEditor/Source/Panels/InspectorPanel.cpp |
1,288 |
Engine/SaveSystem/SaveSystem.cpp |
1,279 |
.cpp files over 500 lines: 158. The largest of the RHI backend files (OpenGL/Vulkan/D3D11/D3D12 devices) are single coherent units — full graphics-API surface implementations — and are reasonable candidates to leave intact rather than fragment.
| File | Lines |
|---|---|
Graphics/RenderGraph.h |
1,125 |
SparkEditor/Source/SceneSystem/SceneFileTypes.h |
1,115 |
Core/EngineSettings.h |
1,079 |
Utils/JsonUtils.h |
963 |
Graphics/GraphicsEngine.h |
957 |
Graphics/BasisTranscoder.h |
912 |
Engine/ECS/Systems/ECSystems.h |
849 |
Graphics/MeshClusterSystem.h |
824 |
Graphics/SVGRenderer.h |
803 |
Engine/DataTable/DataTableSystem.h |
800 |
GameModules/SparkGameFPS/Source/Game/Player.h |
795 |
Physics/PhysicsTypes.h |
779 |
Engine/Networking/NetworkManager.h |
732 |
.h files over 300 lines: 216 (of which 64 exceed 500 lines). Many of the largest are data-heavy headers (SceneFileTypes.h, PhysicsTypes.h, JsonUtils.h, FastNoiseLite.h, FastNoise2SIMD.h) where size is acceptable per the data-heavy-headers exception.
Every one of the original audit's worst monolithic files has been resolved by splitting or deletion:
| Original offender | Then | Now | Status |
|---|---|---|---|
Utils/SparkConsole.cpp |
6,996 | 641 | Resolved — embedded UI stripped |
Graphics/GraphicsEngine.cpp |
4,949 | 13 | Resolved — split into multiple files; .cpp is now a near-empty shim |
Graphics/MaterialSystem.cpp |
4,326 | 486 | Resolved — split |
| Former Visual Scripting system implementation | 4,067 | deleted | Resolved — duplicate system removed |
Graphics/AssetPipeline.cpp |
2,557 | split | Resolved |
SparkEditor/Source/Core/EditorUI.cpp |
2,353 | 1,516 | Reduced (still over guideline) |
Graphics/Shader.cpp |
2,334 | split | Resolved |
The original Physics/PhysicsSystem.h (1,909) and Graphics/RenderGraph.h (1,730) headers have shrunk to 685 and 1,125 respectively; PhysicsTypes.h (779) now holds the data definitions.
The original audit's biggest structural finding was two overlapping ~4,000-line visual-scripting systems (Engine/Scripting/VisualScriptSystem and SparkEditor/VisualScripting/VisualScriptingSystem) totaling ~8,000 lines, neither wired in. Today there is a clean split with distinct roles:
-
SparkEngine/Source/Engine/Scripting/VisualScriptCompiler.{h,cpp}— the engine-side runtime/compiler. -
SparkEditor/Source/Panels/VisualScriptPanel.{h,cpp}— the editor authoring UI (1,773 lines, a top.cppoffender but a single coherent panel).
The duplicate editor VisualScriptingSystem is gone.
AudioMixer is now its own pair (Audio/AudioMixer.{h,cpp}); MusicManager.h defines a separately-named bus mixer, so there is no duplicate AudioMixer class. The original audit had already noted the ODR claim was FALSE.
The original audit's "dead headers" (ChromeTracing, MemoryDebugger, FrameInspector, Tween, DebugDraw, DebugOverlay) were wired into the startup/loop paths in March 2026 and are no longer dead. FileLogger is the exception: it still has zero writers -- its two lifecycle calls were removed in the 2026-09 sweep. Engine log files come from Spark::FileSink, installed by Logger::InstallDefaultSinks (per-user Logs/SparkEngine_<timestamp>.log), and the SPARK_FILE_LOG* macros have no production caller. Where FileLogger.h is still present it is covered only by Tests/TestDebugTools.cpp and is pending a wire-it-in-or-delete decision.
For systems the original audit flagged as orphaned (DecalSystem, NavMesh, Sequencer, MeshLOD, etc.), a current reference scan shows each is now referenced from multiple engine .cpp files (DecalSystem: 6, NavMesh: 7, Sequencer: 3, MeshLOD: 3), indicating they have been wired in or are at least integrated into other systems. A definitive wired-in audit should use tools/check-wiring.sh, which is the maintained source of truth for "Initialize() exists ⇒ called."
# Largest .cpp / .h
find SparkEngine/Source SparkEditor/Source SparkConsole/src \
SparkShaderCompiler/src GameModules -name '*.cpp' \
| xargs wc -l | sort -rn | head -30
# Counts over threshold
find ... -name '*.cpp' | xargs wc -l | awk '$1>500 && $2!="total"' | wc -l
find ... -name '*.h' | xargs wc -l | awk '$1>300 && $2!="total"' | wc -l
# Maintained checker
tools/check-bloat.sh-
Original audit:
.claude/knowledge/codebase-bloat-audit-2026-03-15.md, dated March 15, 2026 (last updated 2026-03-18, with progress notes through 2026-03-31). - Re-measured against codebase 2026-06-08.
- OLD → NEW numbers updated:
- Total source lines OLD 269,770 → NEW ~435,185 (
.h+.cpp+.hpp; codebase grew substantially). -
.cppfiles over guideline OLD 23 (against a 400-line limit) → NEW 158 (against the current ~500-line guideline). -
.hfiles over guideline OLD 24 (against a 200-line limit) → NEW 216 over 300 / 64 over 500. - Largest
.cppOLDSparkConsole.cpp6,996 → NEWOpenGLDevice.cpp2,103. - Largest
.hOLDPhysicsSystem.h1,909 → NEWRenderGraph.h1,125.
- Total source lines OLD 269,770 → NEW ~435,185 (
- Findings now resolved since the original audit:
- All P0 monolith splits confirmed: SparkConsole.cpp (6,996→641), GraphicsEngine.cpp (4,949→13), MaterialSystem.cpp (4,326→486), Shader.cpp, AssetPipeline.cpp, EditorUI.cpp.
- Parallel VisualScripting duplication resolved (editor
VisualScriptingSystemdeleted; clean compiler/panel split remains). - AudioMixer ODR risk confirmed non-existent.
- The 7 previously-dead utility headers are wired in; previously-orphaned gameplay systems now show multiple engine references.
Published from 2b03dc797148. Edit the canonical source in wiki/.
- Documentation
- Docs route
- Wiki index
- Guides
- Tutorials
- Samples
- Examples
- API Reference
- API route
- Reference
- Build Guide
- Dependencies
- FAQ
- Changelog
- Roadmap
- Contributing
- Code of Conduct
- Home
- FAQ
- Getting Started
- Quick-Start Tutorial
- Making Your First Game
- Making Your First Multiplayer Game
- Artist Workflow Guide
- Editor Walkthrough
- Migration Guide
- How SparkEngine Works
- Architecture Overview
- Engine Architecture Flowchart
- Creating a Game Module
- Game Modules (catalog)
- Entity Component System
- Rendering and Graphics
- Physics
- Cloth Simulation
- Audio
- Input System
- Camera System
- Scripting with AngelScript
- Visual Scripting
- AI and Navigation
- Animation
- 2D Systems
- Networking
- Dedicated Server
- Multiplayer Quick Start
- Area Server Architecture
- Scene Management
- Large World Support
- Collaborative Editing
- Coroutine System
- Event System
- Event Response System
- Job System
- UI System
- UI Layout Extensions
- Localization
- Dialogue System
- Destruction System
- Replay System
- Achievement System
- Loading System
- Mod System
- Content Delivery
- Tween System
- Memory Integrity
- Gameplay Systems
- Terrain and Procedural Generation
- Save System
- Persistence System
- Day Night Cycle and Weather
- Cinematic Sequencer
- Runtime Prefabs
- SparkEditor
- Editor Tutorials
- SparkConsole
- SparkDaemon
- Shader Pipeline
- Asset Pipeline
- Asset Validation
- Asset Migration
- Game Packaging
- Online Services
- DataTable System
- Loot and Crafting System
- CSG System
- Font System
- Timer Manager
- Movie Render Pipeline
- HLOD and World Partition
- Remote Debug System
- Selection Manager
- Asset Dependency Graph
- Editor Automation
- File Watcher
- Project Templates
- System Requirements
- VR Support
- Mobile Platform
- Accessibility
- Platform Input
- Platform Certification
- Cross-Compilation: Wine Testing
- RHI Abstraction Layer
- D3D11 Backend
- D3D12 Backend
- Vulkan Backend
- OpenGL Backend
- Metal Backend
- DXR Raytracing
- Hybrid Ray Tracing
- Upscaling (DLSS/FSR)
- Render Graph
- Shader Graph
- GPU Particles
- GPU-Driven Rendering
- Volumetric Fog
- Volumetric Clouds
- Global Illumination
- Virtual Texturing
- Water Rendering
- Clustered Lighting
- Material System
- Post-Processing
- Shadow System
- Particle System
- Decal System
- Sky and Atmosphere
- Foliage System
- Mesh Shaders
- Neural Rendering
- Configuration Reference
- Performance Tips
- Benchmark Framework
- Threading Model
- Fuzz Policy and Parser Security
- Memory Safety
- Memory Management Patterns
- Build System and CMake Modules
- Profiler and Debugging
- Performance Profiling Guide
- Telemetry System
- Crash Reporting
- Golden Image Testing
- Utilities
- Testing
- Fuzz Policy and Parser Security
- Codebase Statistics
- Codebase Health
- Error Handling Patterns
- Hot Reload Overview
- Troubleshooting
- Contributing
- Workflow Patterns
- Build Optimizations
- CI Reproducible Builds
- GitHub API and PR Checks
- Git Rebase Conflicts
- Clang-Format
- Code Quality Violations
- AI Bloat Pattern
- MinGW + Wine Cross-Compilation
- Live Editor Testing
- Engine & Renderer Landscape
- DuetOS Portability Catalog
- Five-Engine Analysis
- Eleven-Engine Analysis
- ThorVG / Unity Graphics Analysis
- Advanced Techniques Catalog
- Third-Party Library Evaluation
- Engine Viability Evaluation
- Engine Feature Recommendations
- Project Recommendations
- Mac Compatibility Analysis
- Codebase Observations
- Codebase Bloat Audit
- Test Suite Audit
- Documentation Coverage Audit
- ThirdParty Dependencies Audit
- Load Test Baseline
- Gameplay Systems Status
- SparkGame Module Status
- Stub and Abandoned Features
- Memory Integrity System
- Memory Safety Evaluation
- Hardware Acceleration Systems
- Jolt Physics Integration
- GPU/CPU Separation Plan
- Daemon Services Architecture
- Reflection & Polymorphism Refactoring Plan
- SparkBuild In-Tree
- Wine No-JobSystem Breakthrough
- Wine Role and Fallback Tiers