PoolStats
| Kind | class |
| Package | debug |
| Full name | debug.PoolStats |
| Source | source/debug/PoolStats.hx |
Allocation accounting for the pooled gameplay objects of play.PlayState.
Notes, sustains, splashes, rating popups and cross fades are all served by
FlxTypedGroup.recycle() pools, but a pool that silently stops being hit (a
destroy() where a kill() was meant, a remove(…, true) on the hot path, a
member spliced out of the group) shows up as garbage-collector stutter long
before it shows up as a bug. Issue #88: HTML5 has no readable managed heap, so
debug.FrameProfiler.queryHeapUsedBytes() reports -1.0 there and the profiler
CSV has nothing to say about the note path on web. These counters are that
missing signal: they are platform independent, and every read is a plain Int.
Semantics, per pool slot:
createdCount— a sprite had to be constructed (pool miss / pool growth).reusedCount— a dead sprite was revived from the pool (pool hit).releasedCount— a sprite left the live set, eitherkill()ed back into the pool or destroyed by a destructive path (song reset, seek,KillNotes).liveCount—spawnCount - releasedCount, i.e. sprites currently out of the pool. A song that reuses well keeps this bounded at the concurrency peak and keepscreatedCountflat after the first few seconds.
A steady state of createdCount == 0 growth with a climbing reusedCount is
the property the pooling work is meant to guarantee; the counters make it
observable in a debug build and assertable in tests/haxe/PoolStatsSpec.hx.
Public fields
| Name | Type | Static | Default | Notes |
|---|---|---|---|---|
NOTE | Int | yes | 0 | final · Parent note sprites, pooled by PlayState.notes. |
SUSTAIN | Int | yes | 1 | final · Sustain (hold) pieces, pooled by PlayState.sustainNotes. |
NOTE_SPLASH | Int | yes | 2 | final · Hit splashes, pooled by PlayState.grpNoteSplashes. |
HOLD_SPLASH | Int | yes | 3 | final · Hold splashes, pooled by PlayState.grpHoldSplashes. |
POPUP | Int | yes | 4 | final · Rating/combo popups, pooled by PlayState.popUpGroup. |
CROSS_FADE | Int | yes | 5 | final · Opponent cross fade ghosts, pooled by the grp*CrossFade groups. |
POOL_COUNT | Int | yes | 6 | final · Number of tracked pool slots. |
Public methods
spawn
static inline function spawn(pool:Int, fromPool:Bool):Void
Records one spawn served by a pool.
@param pool one of the slot constants of this class.
@param fromPool true when the sprite was revived from the pool, false
when it had to be constructed. Callers derive this from the
group size: recycle() grows the group only on a miss.
| Parameter | Type | Default |
|---|---|---|
pool | Int | — |
fromPool | Bool | — |
release
static inline function release(pool:Int):Void
Records one sprite leaving the live set (killed back into the pool or destroyed by a destructive path).
@param pool one of the slot constants of this class.
| Parameter | Type | Default |
|---|---|---|
pool | Int | — |
reset
static function reset():Void
Clears every counter; called when a song starts so numbers are per play.
isValid
static inline function isValid(pool:Int):Bool
Whether pool is a tracked slot.
| Parameter | Type | Default |
|---|---|---|
pool | Int | — |
name
static function name(pool:Int):String
Debug name of a pool slot ("unknown" when out of range).
| Parameter | Type | Default |
|---|---|---|
pool | Int | — |
createdCount
static inline function createdCount(pool:Int):Int
Sprites that had to be constructed for this pool.
| Parameter | Type | Default |
|---|---|---|
pool | Int | — |
reusedCount
static inline function reusedCount(pool:Int):Int
Sprites this pool served by reviving a dead member.
| Parameter | Type | Default |
|---|---|---|
pool | Int | — |
releasedCount
static inline function releasedCount(pool:Int):Int
Sprites that left the live set for this pool.
| Parameter | Type | Default |
|---|---|---|
pool | Int | — |
spawnCount
static inline function spawnCount(pool:Int):Int
Total spawns served by this pool, from the pool or freshly built.
| Parameter | Type | Default |
|---|---|---|
pool | Int | — |
liveCount
static inline function liveCount(pool:Int):Int
Sprites currently out of the pool, never negative. Counts spawns rather than constructions: a pooled sprite is constructed once but retired and revived many times, so only the spawn/release difference tracks live occupancy.
| Parameter | Type | Default |
|---|---|---|
pool | Int | — |
reuseRate
static function reuseRate(pool:Int):Float
Share of spawns served from the pool, 0..1 (0 when nothing spawned yet).
| Parameter | Type | Default |
|---|---|---|
pool | Int | — |
totalCreated
static function totalCreated():Int
Sprites constructed across every tracked pool.
totalReused
static function totalReused():Int
Spawns served from a pool across every tracked pool.
totalSpawned
static function totalSpawned():Int
Every spawn served across every tracked pool.
totalReuseRate
static function totalReuseRate():Float
Share of all spawns served from a pool, 0..1.
summary
static function summary():String
One line per pool that actually spawned something, e.g.
note 12/140 (91%) sustain 8/60 (86%). Built at most once a second by the
FPS overlay, so the concatenations are not on a hot path.
Internals
Private / internal members
| Field | Type | Static |
|---|---|---|
names | Array<String> | yes |
created | Array<Int> | yes |
reused | Array<Int> | yes |
released | Array<Int> | yes |