Skip to content

perf: remove LOD CPU and submission hot spots#924

Merged
github-actions[bot] merged 1 commit into
stagefrom
opencode/brave-planet
Jul 12, 2026
Merged

perf: remove LOD CPU and submission hot spots#924
github-actions[bot] merged 1 commit into
stagefrom
opencode/brave-planet

Conversation

@MichaelFisher1997

@MichaelFisher1997 MichaelFisher1997 commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • retain the Phase 0 LOD profiling baseline now present on stage
  • share frame-keyed LOD visibility and coverage between terrain and water, with cheap rejects before coverage scans
  • default-enable pooled LOD MDI for terrain and water while preserving mixed/direct fallback paths
  • move cache reads, serialization, and writes to a bounded dedicated worker with token/revision validation
  • mesh outside the global manager lock and reconcile paused queued jobs safely
  • add per-level visibility/rejection telemetry to benchmark artifacts

Validation

  • nix develop --command zig build test
  • nix develop --command zig build -Doptimize=ReleaseFast
  • nix develop --command zig build -Dskip-present
  • bounded ReleaseFast traversal benchmark (artifact produced; local GPU-memory SLO exceeded due environment allocation reporting)
  • pre-push formatting and full test hooks

Closes #920

@github-actions github-actions Bot added documentation Improvements or additions to documentation engine game build labels Jul 12, 2026
@MichaelFisher1997
MichaelFisher1997 changed the base branch from dev to stage July 12, 2026 21:03
@github-actions

Copy link
Copy Markdown
Contributor

kcov coverage

Line coverage ran for this PR and uploaded a non-blocking report artifact named kcov-report. Codecov upload is configured as non-blocking while the project captures a stable baseline.

@github-actions

Copy link
Copy Markdown
Contributor

📋 Summary

This PR closes #921 (LOD GPU roadmap Phase 0: establish profiling and quality baselines). It adds opt-in thread-safe CPU profiling for LOD scheduling, generation, meshing, upload, visibility/coverage, eviction, and waitIdle; adds GPU timestamp scopes for LOD terrain and water; extends benchmark artifacts with per-frame LOD attribution, percentiles, and worst-frame analysis; and introduces deterministic benchmark scenarios (stationary, traversal, rapid-turn, teleport-eviction) with documentation.

The implementation largely satisfies the issue requirements: LOD CPU/GPU timings are reported independently, frame percentiles and worst-frame attribution are available, CPU/GPU/synchronization/memory-pressure metrics are distinguished, scenarios are bounded and documented, and instrumentation can be disabled or is negligible when off. A few requested metrics (GPU pool/direct-buffer bytes, lock wait/hold time) are explicitly deferred because the RHI/LOD pool interface does not expose them.

📌 Review Metadata

🔴 Critical Issues (Must Fix - Blocks Merge)

None identified.

⚠️ High Priority Issues (Should Fix)

None identified.

💡 Medium Priority Issues (Nice to Fix)

None identified.

ℹ️ Low Priority Suggestions (Optional)

[LOW] modules/world-lod/src/lod_stats.zig:211 - LODProfilingCollector.reset() is implemented and tested but never called from production code.
Confidence: High
Description: The collector accumulates counters for the process lifetime. For long-running non-benchmark sessions, cumulative values can grow very large and become less useful for UI display over time.
Impact: UI telemetry may eventually show unbounded cumulative values instead of per-session or per-reset deltas.
Suggested Fix: Reset the collector at a sensible boundary (e.g., world load/unload) or expose a reset control if telemetry consumers need windowed measurements.

[LOW] modules/world-lod/src/lod_stats.zig:34 - Issue #921 requested GPU pool/direct-buffer bytes and pool growth/compaction tracking, which are not implemented.
Confidence: Medium
Description: The PR explicitly documents that GPU pool allocations are unavailable through the current RHI/LOD pool interface, but the issue acceptance criteria still list them.
Impact: Phase 0 is still unblocked, but later phases will need to extend the RHI/LOD pool interface or add pool-level accounting.
Suggested Fix: Capture this as a follow-up issue with a concrete interface design (e.g., add a poolBytesUsed/poolBytesReserved callback to LODGPUBridge).

[LOW] modules/world-lod/src/lod_stats.zig:34 - Lock wait/hold time is not tracked separately from waitIdle time.
Confidence: Medium
Description: Issue #921 requested lock wait/hold time, but the current instrumentation only measures waitIdle stalls.
Impact: Main-thread contention on the LOD mutex is not visible in telemetry.
Suggested Fix: Add optional Mutex wrapper timing or instrument lock/unlock pairs around the critical sections.

📊 SOLID Principles Score

Principle Score Notes
Single Responsibility 8 Profiling collector, benchmark runner, RHI timing, and UI display each have clear, narrow responsibilities.
Open/Closed 8 Extends existing stats/timing/benchmark structs without changing core LOD behavior.
Liskov Substitution 8 RHI interface usage is consistent; no inheritance violations.
Interface Segregation 9 LODProfilingCollector exposes only profiling-related operations; UI boundary uses a dependency-neutral projection.
Dependency Inversion 8 Benchmark/UI depend on RHI and world-lod abstractions, not concrete implementations.
Average 8.2

🎯 Final Assessment

Overall Confidence Score: 82%

Confidence Breakdown:

  • Code Quality: 85% (clean, idiomatic Zig; atomic counters; clear naming)
  • Completeness: 80% (most acceptance criteria met; GPU pool/lock metrics deferred)
  • Risk Level: 30% (profiling-only changes; no gameplay or rendering logic changes)
  • Test Coverage: 85% (new unit tests for collector, scenarios, and benchmark summaries)

Merge Readiness:

  • All critical issues resolved
  • SOLID average score >= 6.0
  • Overall confidence >= 60%
  • No security concerns
  • Tests present and passing (if applicable)

Verdict:

MERGE

The PR is well-scoped, well-tested, and low-risk. It establishes the requested Phase 0 baselines with clear documentation of the remaining gaps.

Machine Readable Verdict

{
  "reviewed_sha": "f83e2d8f04c2882b632fbefbf386c149736091cf",
  "critical_issues": 0,
  "high_priority_issues": 0,
  "medium_priority_issues": 0,
  "overall_confidence_score": 82,
  "recommendation": "MERGE"
}

New%20session%20-%202026-07-12T21%3A02%3A39.664Z
opencode session  |  github run

@github-actions
github-actions Bot merged commit 33dab42 into stage Jul 12, 2026
20 of 23 checks passed
@MichaelFisher1997 MichaelFisher1997 changed the title feat: establish LOD profiling and quality baselines perf: remove LOD CPU and submission hot spots Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build documentation Improvements or additions to documentation engine game

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LOD GPU roadmap Phase 0: establish profiling and quality baselines

1 participant