Sparse perspective writeback in UIEntity::updateVisibility (Phase 5.2 finding) #316
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
john/McRogueFace#316
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Source: Phase 5.2 benchmark
tests/benchmarks/fov_opt_bench.py(Kanboard #37). Baseline attests/benchmarks/baseline/phase5_2/fov_opt_bench.json.Finding
UIEntity::updateVisibility()(src/UIEntity.cpp:42) does two full-grid passes per call:On a 1000x1000 grid, the per-entity update is dominated by the two W*H walks (1M ops each), not the actual TCOD FOV computation:
For 100 entities updating per turn this is ~3 seconds/turn on a 1000x1000 grid even with cheap algorithms.
Suggested optimization
Both passes should be bounded by an AABB around the entity sized to
fov_radius:Then walk only
[y0..y1) x [x0..x1)for both demote and promote. Cells outside that window cannot transition state for this entity in this tick (they are not in FOV), so leaving them at their stored value is correct. For radius=32 on 1000x1000 this drops the cost from 1M to ~4225 cells per pass -- expected ~250x speedup on the writeback portion.Caveat: with
fov_radius=0(unlimited) the bounded walk degenerates to the full grid; behavior is unchanged. The current full-grid loop is the right answer when radius is unlimited.Validation
The bench in this commit can be re-run to confirm the speedup:
Diff against
tests/benchmarks/baseline/phase5_2/fov_opt_bench.json.Labels
system:performance, system:grid, priority:tier2-foundation, Minor Feature, workflow:needs-benchmark