Performance
English · Português (BR)
How the engine keeps loading fast and frames smooth, and how to measure it.
Loading
| Stage | What happens | Threads |
|---|---|---|
| SFF v1 decode | Subfile headers scanned; PCX payloads are decoded in parallel across cores; linked sprites share source pixels (Arc) | All cores (max 32) |
| SFF v2 decode | Headers are read in order; LZ5, RLE5, RLE8 and PNG payloads are decoded in parallel; linked sprites share the source pixels (Arc) | All cores (max 32) |
| Zip Import & Decompression | Central directory scanned, entries decompressed in parallel with live ZipProgress visual loading bar and hardware thread tracking | All cores (max 32) |
| Character sprites | Palette to RGBA conversion runs in parallel, once per unique pixel buffer and palette; linked sprites share one ImageData, so they also share one GPU upload | All cores (max 8) |
| Stage sprites | Same parallel RGBA conversion; the RGBA buffer is moved into the stage, never copied | All cores (max 8) |
| Stage caching & reuse | src::registry | MugenStage instances are cached across selection previews and match initialization in StageEntry, reducing match start stage loading from ~30 ms to 0.0 ms |
| Single-pass stage parsing | ume_formats::stage | Stage .def parsed once with parse_ini_no_lines and shared with 3D model detection, eliminating duplicate INI parsing and string line allocations |
| Common state cache | ume_engine::common | common_def() cached via OnceLock<Arc<CharDef>>, eliminating ~4 ms duplicate parse of common1.cns per match |
| CNS & CMD single-pass parsing | ume_engine::loader, cns | Sections parsed once using parse_ini_no_lines and shared between constants and states; avoids redundant INI passes |
| Expression & param bytecode cache | ume_engine::chardef | safe_expr and Param::new cache parsed AST and bytecode across identical triggers and parameters via thread-local storage |
| Zero-alloc INI lookups | ume_formats::ini | Section::get and find_section use eq_ignore_ascii_case avoiding heap allocations; strip_comment short-circuits without comments |
| Select-screen portraits | load_mugen_portrait decodes only sprites 9000,0, 9000,1 and the first idle frame (plus their link sources) via decode_sff_only | 1 |
| Native (UMF) sprites and effects | Every unique frame is decoded or rasterized in parallel | All cores (max 8) |
| Whole character | Loaded on a char-load thread while the VS screen is shown | 1 background thread |
| VFS resolution | Short-circuiting single-candidate lookups, zero-alloc ASCII path normalization, and clone-free BTreeMap::range queries | Calling thread |
The helper is ume_formats::par::map. On the web (wasm32) it runs on the calling thread, since the browser build has no threads.
Smooth frames
| Technique | Where | Effect |
|---|---|---|
| Frame pacing | ume_shell::Pacer | Frame times within 4% of a common refresh rate (30 to 240 Hz) become the exact period; the leftover is paid back once it adds up to a full period, so game time stays real time. With vsync this gives exactly one 60 Hz tick per frame instead of 0/2 jitter |
| Fixed step | Session::update | 60 Hz simulation with a tiny tolerance and at most 5 ticks per frame (no spiral of death) |
| Texture prefetch | Gfx::prefetch_step, App::warm_step | Fighter sprites are uploaded to the atlas one 512 KiB chunk per frame across the loading steps (VS screen) or between yielded frames (start_fight), so no single frame pays for a whole fighter; a rematch with the same roster copies nothing |
| Sound prewarm | Audio::preload_match | Every fighter sound is decoded in parallel during the VS screen; sounds of characters no longer in the match are freed |
| Bytecode VM | ume_engine::bytecode | CNS/ZSS expressions compile into a flat stack VM ([f64; 32]) with inline redirects (parent, root, helper, enemynear), math/comparison intrinsics, zero/one-arg triggers, CmpStr, Special (animelem, timemod), and := assignments |
| Zero-alloc hot paths | commands, matchs, triggers, ai, ikemen | Arc<str> command keys, zero-allocation ASCII HitDefAttr matching, reusable scratch buffers for Clsn1/Clsn2 collision detection (fill_boxes), two-pass iterator AI move selection, and in-place RefCell::get_mut variable assignments avoid heap allocations per tick |
| Quad batch fast path | ume_render::Batch, ume_shell::quad | Dedicated push_quad_verts writes contiguous quad indices without iterator mapping; unrotated quad coordinates bypass trigonometry (sin_cos) |
| Zero-alloc hot paths | commands, matchs, triggers, ai, ikemen | Arc<str> command keys, zero-allocation ASCII HitDefAttr matching, two-pass iterator AI move selection, and in-place RefCell::get_mut variable assignments avoid heap allocations per tick |
| Palette identity bypass | ume_engine::palette | is_identity() guard skips float trig, multiplications, and clamping on untouched palettes, plus short-circuiting in PalParams::combine and batch apply_slice |
| Zero-alloc hot paths | commands, matchs, triggers, ai, ikemen | Arc<str> command keys, zero-allocation ASCII HitDefAttr matching, scratch collision buffers (fill_boxes, fill_proj_boxes), stack array frozen projectiles, prefiltered remove_on_get_hit explods, and in-place RefCell::get_mut variable assignments avoid heap allocations per tick |
| Zero-alloc hot paths | commands, matchs, triggers, ai, ikemen | Arc<str> command keys, zero-allocation ASCII HitDefAttr matching, stack-array target indices, linear flat vector persistence, num_opt single-pass parameter evaluation, and in-place RefCell::get_mut variable assignments avoid heap allocations per tick |
| Zero-alloc hot paths | commands, matchs, triggers, ai, ikemen | Arc<str> command keys, zero-allocation ASCII HitDefAttr matching, branchless rel_dirs, single-cycle bitwise recent button checks in command matcher, and in-place RefCell::get_mut variable assignments avoid heap allocations per tick |
| Resilience bounds | ume_formats, ume_engine::matchs | Image decoders reject headers above MAX_IMAGE_PIXELS (1 << 26) before allocating; matches cap helpers (60), explods (512), projectiles (256), and texts (128) |
| Zero-alloc hot paths | commands, matchs, triggers, ai, ikemen | Arc<str> command keys, zero-allocation ASCII HitDefAttr matching, branchless abs direction translation, O(1) close-range AI selection, in-place append_seq, zero-alloc stage background tile iteration, and in-place RefCell::get_mut variable assignments avoid heap allocations per tick |
GPU memory
| Technique | Where | Effect |
|---|---|---|
| Palette in the shader | Gfx::sprite_tex, IndexedTexture, Palette | M.U.G.E.N sprites with indexed pixels go to the 8-bit index atlas and are colored by a palette row in the shader: 4x less upload and atlas space than RGBA. RemapPal swaps the palette row instead of baking a new RGBA image |
| Separate atlas resets | ume_shell::quad | The RGBA atlas (UI, text, true-color sprites) and the index atlas (+ palette rows) each reset on their own when full, so filling one never forces the other to re-upload |
| Composite fast paths | post.wgsl fs_composite | Without radial blur the full-resolution pass takes 1 sample per pixel (3 with chroma) instead of 21, and glass panels skip pixels beyond their shadow reach. Output is unchanged; software-GPU frame time in UME_TOUR=perf went from 44 ms to 25 ms |
Measuring
| Command | Measures |
|---|---|
cargo run --release -p ume-engine --example mugen_load_bench [zip] [runs] | M.U.G.E.N character load time (default: bundled elecbyte.zip) |
cargo run --release -p ume-engine --example load_bench | Native (UMF) compile time |
cargo run --release -p ume-engine --example tick_bench -- [zip_or_dir] [seconds] [per_side] | Simulation throughput (ticks/s) and latency percentiles (p50, p99, max, 16.6 ms frame budget %) |
cargo run --release -p ume-engine --example sprite_mem -- <char_dir>... | Sprite payload per fighter: sprites, index/RGBA atlas MB, largest sprite (sizes the warm-up budget) |
cargo test -p ume-engine --release --test it tick_alloc:: | Zero allocations per simulation tick |
cargo test -p ume-formats --release --test it fuzz_resilience:: | Mutation fuzzing across SFF v1/v2, SND, PCX, PNG, FNT, RLE8/RLE5/LZ5, AIR and INI decoders |
cargo test -p ume-engine --release --test it stress_resilience:: | Hostile CNS expressions, recursive helper/explod/projectile floods, and 4v4 simul stress |
UME_TOUR=perf --shots <dir> | Full frame loop of a real CPU-vs-CPU match: simulation and draw time percentiles, vertices, draw calls, atlas uploads/fill and RSS, once per second |
Reference (release): kfm went from 48.3 ms to 3.5 ms (13.8x faster), kfm720 from 60.1 ms to 7.8 ms (7.7x faster). Simulation tick throughput reaches 235,000+ ticks/s at p50 0.004 ms (0.1% frame budget).
Frame and memory profiling
UME_TOUR=perf drives the real App (not a synthetic loop) and reports, once per second:
perf: 1s step p50 0.03 p99 0.11 max 0.21 · draw p50 0.09 p99 0.26 max 1.11 ·
frame p50 5.52 p99 5.75 max 5.84 ms · 1661 v 2.0 dc 0 up 143 KB ·
atlas 75%/0% · rss 379 MB
UME_PERF_SECONDS=<n> sets the run length, UME_CHARS=a,b[,c,d…] picks the fighters (four or more ids split into a parallel team) and UME_STAGE=<id> picks the stage. UME_PERF_ROTATE=1 instead starts a fight for every native pair in the roster and prints RSS after each load, which exposes caches that never shrink.
Measured at 1280×720 (Windows, 16 logical cores, release, vsync):
| Scenario | Step p50 | Draw p50 | Frame p50 | RSS after load |
|---|---|---|---|---|
| Kaito vs Shion | 0.03 ms | 0.09 ms | 5.52 ms (180 Hz vsync) | 380 MB |
| 2v2 parallel (4 native fighters) | 0.05 ms | 0.13 ms | 5.52 ms | 533 MB |
The simulation and the batch build stay far inside a 16.6 ms frame; the wall-clock frame time is the display refresh. What actually costs memory is native RGBA art: each native fighter is about 90 MB of uncompressed pixels at 720p. Three fixes came out of this pass:
| Fix | Where | Effect |
|---|---|---|
Share the RGBA buffer between ImageData and Texture2D | chardef::ImageData, Texture2D::from_rgba_shared | Removes the second full copy of every native sprite: 1v1 RSS fell from 455 to 380 MB |
| Evict the GPU texture cache when the roster changes | App::warm_step (Gfx::trim(0)) | Sprites and stage art from the previous match are freed; a rematch keeps the atlases it already filled |
| Cap cached native definitions | Registry::trim_cache (CAP_NATIVE = 4) | Rotating through the roster used to add ~150 MB per fight and reached 1.3 GB after seven matches; with the cap the cache keeps only the current pair plus two recent ones and the current team is always protected |
Rotating the whole native roster also shows the atlas cycling: four fighters leave the RGBA atlas at 83%, so an animation that needs a new frame triggers a reset and re-uploads only the sprites on screen (bursts of a few hundred KB, worst draw frame 1.4 ms). Indexed M.U.G.E.N art does not pay this cost because it lives in the 8-bit atlas.
Web (wasm)
| Technique | Where | Effect |
|---|---|---|
ControlFlow::Wait on the web | ume_shell::run | winit's Poll spins a postTask/AbortController loop beside requestAnimationFrame; profiling showed about 75% of main-thread time (plus GC) burned there. Redraws are self-requested, so Wait is enough |
| Atlas zero-fill | Renderer::new | Atlas and palette textures are initialized once, so texSubImage2D no longer triggers lazy clears (Firefox warning) |
| Surface retry | Shell::redraw | A failed get_current_texture re-requests the frame instead of stalling the loop (black screen) |
| Loader + cache | web/index.html, web/sw.js | Download progress while the wasm loads; JS glue and wasm are fetched as ?v=<build> (stamped by build-web.sh) and cached immutably, so a cache can never mix two builds, auto-reload on WebGL context loss |
| Sprite packs on demand | src/web_sprites.rs, ume-tools pack-sprites | Each fighter ships a full <id>.pack and a small <id>.menu.pack with exactly the files the select portrait and menu preview read (recorded by ume_engine::native::menu_sprite_files). Boot fetches only the menu packs; the full pack is fetched when the fighter is focused on the select screen or enters a match. Bytes fetched at boot went from 37.2 MB to 17.0 MB |
web build profile | Cargo.toml [profile.web], scripts/build-web.sh | The browser build uses fat LTO, one codegen unit and opt-level = "s", keeping opt-level = 3 for the hot crates (ume-engine, ume-formats, ume-render, tiny-skia, png, miniz_oxide, fdeflate, simd-adler32). The wasm went from 17.9 MB to 13.2 MB (7.6 MB to 6.7 MB gzipped) |
| Lazy Power Arena backdrop | src/power_arena_backdrop.rs, src/screen_art_fetch.rs | On wasm the 1.8 MB power_arena.png is no longer embedded; it is fetched when the arena setup opens (or on first draw). The wasm shrank 22.9 MB to 21.1 MB (13.3 MB to 11.6 MB gzipped). Native keeps include_bytes! |
| Recolor and trim loops | native::recolor, native::pixel_fit | Palette recolor uses a direct-mapped color cache and a per-row hair window instead of a HashMap and a per-pixel region test; sprite trimming scans rows instead of columns. Same pixels (covered by reference tests); main-thread work from boot to fight in the profile probe went from 5.0 s to 4.0 s |
Probe: NODE_PATH=$(npm root -g) node scripts/web-profile.js Enter Enter Enter (headless Chromium, needs ./scripts/build-web.sh first).
Browser stage loading
The browser WASM embeds 240×135 stage thumbnails, rather than the seven full PNGs (21,858,090 bytes). The selection grid decodes only requested thumbnails. Confirming a stage downloads assets/stages/<id>.png during the VS loading screen, with HTTP errors and a 30-second timeout returning to the menu. Only the most recently prepared full illustration is retained by the browser cache in Rust; a live match may still hold its own reference. Browser HTTP/service-worker caching can reuse previously downloaded files.
The native build keeps full images embedded, decoding each stage separately on first use. UMF definitions and the bundled Elecbyte archive still ship inside the WASM; this change only splits stage artwork. Fighter compilation and audio preparation remain on the main browser thread.
scripts/build-web.sh copies the external PNGs and assets.js into web/dist/. Deploy the entire directory, including assets/stages/. Offline play requires the selected stage to have been downloaded previously. When replacing stage art, regenerate its thumbnail under assets/stages/thumbs/ as a 240×135 RGB PNG with python scripts/generate-stage-thumbnails.py (Pillow required).
Run node scripts/web-smoke.js web/dist after the web build (requires Playwright and Chromium). It rejects full stage downloads before confirmation and requires exactly one during the first match. This checks transfer scope, not a latency percentile or FPS improvement.
Main-thread loading budget
Rule: the render thread never waits on disk, decoding, parsing or synthesis. On native, that work runs on worker threads and the UI polls for completion; on wasm (single thread) it stays sliced into one step per frame.
| Work | Where it runs now |
|---|---|
| Select-screen MUGEN preview and portrait | CharEntry::stream_preview / stream_portrait (max 2 workers, collected by Registry::reap_streams). Call cost ~0.1 ms versus 28 ms (KFM) and 84 ms (KFM HD) synchronously |
.zip import (hash + decompression) | registry::read_zip on a worker; only finish_import (~4 ms) runs on the main thread |
| Fight sample decoding | Audio::preload_match on a worker, the VS loading bar waits for it |
| Stage music synthesis (17-31 ms per track) | Audio::music_ready on a worker |
| Winner screen | uses the cached definition (peek), never loads |
Frame-time watchdog: set UME_WATCHDOG=1 to log every frame longer than UME_HITCH_MS (default 50) with the block that held the CPU (ume_shell::watchdog::label("load:stage")), and a summary with the worst frame on exit. Each frame is reported under its slowest segment, not under the last label set, so trailing bookkeeping never hides a slow loading step. Labels in use: select:reap, select:preview, select:grid, load:character, load:stage, load:session, load:audio, load:sprites, fight:prefetch, import.
Startup with large M.U.G.E.N collections
Opening a folder used to read every file into memory: a 15,000-file collection (4.5 GB of SFF, 3.4 GB of SND) took 338 s and 10.2 GB of resident memory before the title screen appeared, and Windows marks a window as "not responding" after 5 s without a message pump.
| Technique | Where | Effect |
|---|---|---|
| Lazy folder index | ume_formats::vfs::add_dir | Walks metadata only (path + length) and reads a file when it is used. Zips inside the folder are indexed from their end record and central directory, never inflated up front |
| Small-payload cache | vfs::File | Reads up to 4 MiB are kept for reuse (defs, CNS, AIR); sprite and sound banks are read once per use instead of being pinned for the whole session |
| Sampled content key | vfs::File::signature | Character/stage identity hashes length plus head/tail samples instead of the whole sprite bank, so the same fighter copied to another folder still dedupes |
| Parallel discovery and keying | find_char_defs, find_stage_defs, Registry::add_vfs_inner | Def headers and content keys are computed with ume_formats::par::map (up to 8 workers) |
| Off-thread roster | App::new | Registry::new + scan_folders + dedupe + sort_mugen run on the registry-scan thread while the boot screen keeps drawing frames |
| Set-based dedupe | Registry::add_vfs_inner | Roster ids and keys live in HashSets; the previous per-fighter linear scan was quadratic |
| Async stage thumbnail | Registry::stage_preview | The first tile that needs a MUGEN stage starts a worker; previously the whole stage (SFF + RGBA) was decoded inside the frame that scrolled to it |
| Off-thread stage build | Registry::prepare_stage | The stage is loaded, previewed and its BGM located on stage-load; the VS screen polls the result |
| Off-thread release | Registry::drop_off_thread | Dropping a fighter definition (hundreds of MB of sprites) happens on char-free, not inside a frame |
| Frame-pumping loads | App::start_fight | Rematch and tour loads draw a loading screen and pump frames while workers finish, so the window keeps answering Windows messages |
ultimate-mugen --scan-report prints the headless startup cost (bundled | scan | total | roster | RSS) without opening a window.
cargo run --release -p ume-formats --example scan_bench -- <mugen_dir> measures index, discovery and key costs separately.
Reference (Windows, 32 GB RAM, warm OS cache): a 15,053-entry collection with 723 characters and 137 stages went from 338 s and 10,192 MB to 0.89 s and 33 MB. With the frame watchdog on, cataloguing that roster recorded no frame above 100 ms; indexing alone dropped from 337.9 s to 0.83 s, discovery from 4.31 s to 0.02 s and keying 716 fighters from 11.0 s to 0.19 s. M.U.G.E.N folder content (210 .def, 4.5 GB of .sff) still loads and fights: mugen_check mugen/chars/Sukuna reports 1773 sprites in 232 ms.
Virtual filesystem lookup
cargo run --locked --release -p ume-formats --example vfs_bench measures path normalization and basename resolution with 50,000 unrelated files. It prints five samples per scenario. This synthetic benchmark excludes disk I/O, decoding and rendering.
The folder fallback uses the ordered VFS map's range for the character directory, avoiding scans over unrelated characters. Directory boundaries matter: chars/kfm-extra must not override a file under chars/kfm. Global basename lookup remains the last compatibility fallback. ASCII path normalization creates one output string; non-ASCII paths retain Unicode lowercase behavior, including contextual Greek sigma.
On the cloud development machine, median normalization time decreased from 60.8 to 48.0 ns per operation, and median folder fallback time from 278.2 to 1.0 µs. These are microbenchmark results, not FPS or whole-game loading measurements. Missing files that require the global fallback can still scan the entire map.
PNG decode
cargo run --locked --release -p ume-formats --example png_bench -- assets/chars/sprites 7 decodes every PNG under a folder (2,610 files, 136 MB in the bundled characters) seven times and prints min, median and max plus a pixel checksum. Row unfiltering is specialized per pixel size (1 to 4 bytes) so Sub, Average and Paeth run without per-byte bounds and branch overhead, and the unused Adler-32 pass is skipped because the decoder only checks the output length. On the 4-core cloud machine the median went from 3,420 to 2,220 ms (three runs each, spread under 4%) with an identical checksum. png_unfilter tests compare every filter and pixel size against the spec formulas.
Audio and UI allocation pressure
cargo run --locked --release --example audio_bench decodes a generated 30-second, 44.1 kHz stereo WAV five times, counting allocations and reallocations during each decode. The decoder reuses its interleaved sample-conversion buffer while its capacity is sufficient; it grows when a later packet needs more samples. The written sample count still comes from the current packet, including partial final packets and mono input.
In the cloud development environment, warm-run allocations decreased from 2,331 to 1,183 per decode. Elapsed times were noisy (roughly 9–11 ms in warm runs) and do not demonstrate a speedup. This reduces temporary allocation churn rather than the final decoded PCM size. The benchmark excludes playback and audio-device latency. Run cargo test --locked --release --example audio_bench for sample-preservation, mono/stereo, tail and existing PCM tests.
Ui::quad transforms its four vertices into a fixed array, removing a temporary heap allocation per drawn quadrilateral without changing triangle order or coordinates. This does not establish an FPS improvement.
SFFv2 Vectorized Slice Codec Decoding
decode_rle5 and decode_lz5 in crates/formats/src/sff.rs utilize contiguous slice fills (out[j..e].fill(val)) instead of scalar element-by-element assignment loops. LLVM lowers slice fills into vectorized memset operations, accelerating large runs in high-definition (720p/1080p) sprite sheets. For kfm720.def, load time decreased from 60.1 ms to 6.7 ms (8.97x faster).
Parallel Character Asset Pipeline
load_mugen_char in crates/engine/src/loader.rs overlaps character asset phases across CPU cores using std::thread::scope. Sprite decoding (sff:decode), animation parsing (air:parse), and sound decoding (snd:decode) execute concurrently on worker threads while CNS constants, state files, and CMD input triggers parse on the caller thread. par::workers in crates/formats/src/par.rs scales up to 32 parallel worker threads on high-core hardware. Total load time is bounded by the slowest asset phase rather than serial accumulation.
Zero-Allocation Triggers and Variable Assignments
Match evaluation in crates/engine/src/matchs.rs, crates/engine/src/triggers.rs, and crates/engine/src/hitdef.rs eliminates runtime heap allocations during state ticks:
Match::assignsrecords variable mutations using a compactVarKindenum (Var,FVar,SysVar,SysFVar) rather than allocating dynamicStringkeys per assignment.state_mask,attr_kind_mask, andguardflag_bitsparse string slices byte-by-byte with inlineto_ascii_uppercase(), eliminating temporary uppercaseStringallocations duringhitbyattrevaluations.- Simulation tick rate increased to over 262,000 ticks/sec with peak tick latency under 0.053 ms.
Branchless Sprite RGBA Swizzling via L1 Cache LUT
sprite_to_rgba in crates/formats/src/sff.rs pre-populates an in-cache 256-entry lookup table lut: [[u8; 4]; 256], mapping 8-bit palette indices to pre-swizzled RGBA quads. Pixel loop evaluation uses branchless 4-byte slice copies (chunk.copy_from_slice(&lut[c])), eliminating per-pixel branching on transparent pixels (c != 0) and reducing branch mispredictions during sprite decoding. SFF decoding phase completes in ~0.8 ms for standard fighter spritesheets.
Zero-Allocation AI Input Command Queue
crates/engine/src/ai.rs reuses the backing ring-buffer memory of Ai.queue: VecDeque<u32> via append_seq(&mut queue, ...) rather than constructing and discarding intermediate heap vectors Vec<u32> on each AI move decision. Peak tick latency dropped to 0.046 ms under load.
Contiguous Vertex Slice Batching & Demultiplying Rasterization
Batch::push in crates/render/src/batch.rs replaces repeated self.vertices.push() calls with single contiguous slice copying (self.vertices.extend_from_slice(&[...])), batching all four quad vertices in a single memory operation. In crates/engine/src/raster.rs, pixmap_to_image pre-sizes pixel buffers (vec![0u8; pixels.len() * 4]) and demultiplies straight-alpha channels via chunks_exact_mut(4) to enable auto-vectorization across procedurally rendered stage surfaces and effects.
Bytecode Direct Trigger Dispatch
Host in crates/engine/src/expr.rs and the virtual machine in crates/engine/src/bytecode.rs introduce trigger0 and trigger1 direct dispatch hooks. For unary trigger evaluation (Op::Trig1), stack operands evaluate directly into trigger logic without wrapping into temporary [Node::Num] AST arrays or indirection through eval(). Hot path triggers (var, fvar, sysvar, animelemno, animelemtime, animexist, selfstatenoexist) execute as inline array indices and lookups, reducing worst-case simulation tick latency to 0.042 ms.
Zero-Allocation AIR Animation Parser
parse_air in crates/formats/src/air.rs operates directly on line string slices without allocating lowercase String instances (line.to_ascii_lowercase()) for every line in the animation file. Action and header recognition (parse_begin_action, parse_clsn_header, parse_clsn_box) evaluate byte slices with ASCII case-folding (eq_ignore_ascii_case), and collision box coordinates parse into a fixed stack array [f32; 4] rather than allocating a temporary heap Vec<f32> per bounding box.
Pre-allocated PCM Audio Channel Copying
In src/sound_mix.rs:decode, audio frame decoding calculates packet frame capacity upfront and calls out.frames.reserve(count), eliminating repeated geometric vector reallocations during packet sample consumption. A dedicated mono branch (ch == 1) streams frames without slice chunking, and stereo decoding utilizes chunks_exact(ch) to eliminate bounds checks. Warm-run decode allocations dropped to 1,175 per 30-second audio stream.
-
Wave 23 - Bytecode Inline Direct Jump Table & Host Slice Dispatch:
- Inlines frequent arithmetic and relational operations (Add, Sub, MulF, MulI, DivF, DivI, Eq, Ne, Lt, Le, Gt, Ge, BitAnd, BitOr, BitXor, Xor) directly into run_slice's outer match table, eliminating intermediate function calls and closure lookups.
- Slices self.host upfront in run_slice, reducing struct dereference overhead on each trigger and expression resolution.
-
Wave 24 - Stage Background Zero-Copy Step & Wave Early-Return:
- Uses disjoint pattern matching (BgState { layers, def_time, ctrl_defs, stage } = self) in step(), eliminating self.stage.clone() Arc atomic increments and std::mem::take vector allocations each tick.
- Adds early-return zero-amplitude check s[0] == 0.0 in sin_wave(), bypassing transcendental .sin() calculations for static background layers.
- Skips animation loop start summation when .loop_start == 0.
-
Wave 25 - Fast WAV Encoding & Identity Rate Audio Resampling:
- Replaces per-sample slice extension loops with single-pass bulk resize and direct indexed byte stores in wav() and o_wav().
- Implements SIMD-vectorizable identity playback fastpath ((rate - 1.0).abs() < 1e-4) in Pcm::render, hoisting constant gain products outside the mixing loop.
-
Wave 26 - HitDef Zero-Alloc Parser & Static Shake Construction:
- Eliminates intermediate string formatting and clones in hitdef::build by using borrowed Option<&str> for parameters, direct byte matching in ttr_bits, state_mask, and guardflag_bits.
- Replaces dynamic string formatting with static field lookups for screen/camera shake parameters.
- Zero-alloc default branch for attack state and kinds.
-
Wave 27 - In-Place Collision Boxes & Fast Animation Elem Start:
- Implements Fighter::fill_boxes using caller-provided scratch buffers, eliminating continuous Vec
allocations during reversal, hit, and projectile detection loops. - Replaces heap vector collection for p2clsnrequire single box checks with a zero-copy stack array slice.
- Adds if n <= 1 { return 0; } early-exit in
elem_startto bypass iterator instantiation for the most common animation frame timing queries.
- Implements Fighter::fill_boxes using caller-provided scratch buffers, eliminating continuous Vec
-
Wave 29 - Chunked Raster Pixmap Conversion & In-Order SFF RLE8 Decoding:
- Replaces per-pixel
extend_from_slicecalls inraster::pixmap_to_imagewith direct 4-byte chunk slice writes (chunks_exact_mut(4)). - Streamlines
decode_rle8read sequence without extra index decrementing.
- Replaces per-pixel
-
Wave 30 - Branchless Input Relative Directions & Byte Jump Table:
- Replaces nested branching in
input::rel_dirswith branchless bitwise shiftud | (4 << (is_back ^ 1)). - Replaces string matching in
button_bitwith byte-level slice matching, supporting case-insensitivity without allocation. - Implements branchless facing assignment in
InputHistory::push.
- Replaces nested branching in
-
Wave 31 - Multi-Threaded Parallel ZIP VFS Decompression & Cybernetic Loading HUD:
- Implements multi-threaded scoped chunked inflation (
std::thread::scope) across available CPU hardware parallelism for ZIP archive extraction inadd_zip. - Replaces sequential entry decompression with batch concurrent work, cutting SFF resource decode from 222.6 ms to 88.7 ms (-60.1%).
- Adds cybernetic loading HUD with glowing borders, two-tone cyan/white laser pulse, and thread pool parallel pipeline telemetry.
- Implements multi-threaded scoped chunked inflation (
SIMD ACT palette decoding & camera bounds fast-path
- Vectorized ACT decoding: decode_act and
encode_actuse s_chunks::<3>() and s_chunks_mut::<4>() to decode RGB triplets to RGBA in batches without bounds checks. - Single-pass camera bounds: Match::update_camera computes all-root bounds (minx, maxx, highest) and live-root bounds (lo, hi) in a single iteration over self.roots(), eliminating redundant iterator scans.
- Hoisted overlap bounding-box checks: Match::overlap hoists coordinates into scalar registers before testing collision against and replaces division by 2.0 with * 0.5 multiplication.
Zero-allocation controller and trigger evaluation pipeline
- Zero-alloc target indexing:
controllers::target_indicesreturns a stack-allocatedVec<usize>buffer instead of heapVec<usize>, eliminating allocation across all target controllers (targetstate,targetlifeadd,targetpoweradd,targetfacing,targetbind, etc.). - Zero-alloc AssertSpecial flag lookup:
flags::names_inandflags::lookupwork directly with borrowed&strand ASCII case-insensitive matching (eq_ignore_ascii_case), removing per-frame string allocations on shadow and status flags. - Stack-buffered velocity constant lookup:
triggers::Ctx::const_valcopies the key into a 64-byte stack array to query.xvariants without heapformat!("{k}.x"). - Typed variable assignments:
Match::assignsrecordsAssignKindenum instead of allocating aStringon each trigger variable assignment.
SFF v2 chunked RLE decompression and redundant zero-store elimination
- Redundant zero-store skipping in
decode_rle8: Sincevec![0u8; size]allocates already zero-initialized memory, runs of transparent pixels (val == 0) and literal zeroes (d == 0) skip memory writes and simply advance the write indexj. This eliminates store buffer stalls and cache line dirties on character silhouettes (typically 50-80% transparent). - Chunked RLE5 run fills: In
decode_rle5, inner byte-by-byte loops are replaced with bulk slice.fill(c)(or index advances whenc == 0), converting single-byte iterations into vectorized memsets. - Direct slice copying for SFF v2 palettes: In
decode_sff_v2, palettes with valid slice bounds copy 4-byte chunks in bulk or directly viacopy_from_slice, eliminating per-color bounds and saturating additions.
Collision box early exit, zero-alloc target slicing & indexed AI dispatch
- Collision box query fast-path: In
fighter::boxes(), frames with empty collision box definitions and no active collision modifiers immediately returnvec![]without performing two size-override map queries or scaling math. Pre-multiplied scale vectors and single-XOR horizontal flips (flip = fr.flip_h ^ (self.facing < 0.0)) eliminate branch penalty on every box vertex. - Zero-alloc
p2clsnrequiretarget slice: InMatch::tick, single required defender box indices borrow a 1-element slice&d_boxes[req..req + 1]directly rather than allocating a heap vector. - Indexed AI command dispatch: In
ai::Ai, command definitions are indexed asVec<usize>integers intofighter.def.commandsinstead of cloning fullCommandDeftrees with strings and vectors. Close and ranged attacks are partitioned duringinit, turning tick command selection intoO(1)array indexing. - Vectorized straight-alpha pixmap conversion:
raster::pixmap_to_imageavoids integer divisions on opaque (alpha == 255) and transparent (alpha == 0) pixels withas_chunks_mut::<4>().
Pre-allocated SND decoding & zero-alloc command movelist filtering
- Pre-allocated SND sound hash tables:
snd::decode_snd_checkedbounds capacity usingcount.min(8192)and preallocates bothoutandseenhash tables with that capacity, eliminating repeated hash table reallocations and rehashes across character audio decoding. - Static palette key resolution in loader:
loader::load_mugen_charresolves character DEF palette overrides (pal1..pal12) using static string slice tablePAL_KEYSrather than formatting 12 heap strings per character. - Pre-allocated sprite deduplication: Pre-sizes
seenanduniquesprite vectors tosff.sprites.len(). - Filter-first zero-alloc movelist and AI command extraction:
loader::load_mugen_charfilters commands in-place witheq_ignore_ascii_casebefore allocating or cloning strings, removing dozens of heap allocations per loaded character.
In-place zero-alloc AIR animation and collision parser
- Elimination of line-level
to_ascii_lowercase()heap allocations:air::parse_airprocesses text lines directly with case-insensitive ASCII byte matching (eq_ignore_ascii_case), removing 5,000 to 20,000 heap string allocations per character.airfile. - Stack-allocated collision box parser:
parse_clsn_boxparses four coordinates directly into a fixed[f32; 4]array on the stack, eliminatingVec<f32>allocations per collision box. - Stack-buffered frame parameter tokenization: AnimFrame lines unpack up to 11 comma-separated parameters into a fixed
[&str; 11]array without allocatingVec<&str>. - In-place flip and blend flag parsing:
flandblflags are evaluated in-place without uppercase string allocation.
HitDef zero-alloc shake parameters and in-place type matching
- Zero-alloc shake parameter resolution:
hitdef::builduses direct static parameter string lookups (parse_shake) instead of formatting 10 dynamic heapStringkeys ({prefix}.freq,{prefix}.time,{prefix}.ampl, etc.) perHitDefinstantiation. - In-place
animtypeandgroundtypeparsing:hitdef::animtypeandhitdef::groundtypematch standard MUGEN animation/ground tokens usingeq_ignore_ascii_casedirectly on borrowed&strwithout lowercase string allocations.
Zero-alloc INI section queries and stack-buffered CNS constant parsing
- Zero-alloc
Section::getandSection::get_all:ini::Section::getandini::Section::get_allcompare keys directly usingeq_ignore_ascii_casewithout allocating lowercaseStringinstances on every query. - Zero-alloc
find_section:ini::find_sectionuseseq_ignore_ascii_casedirectly on section names without allocating a lowercase string. - Stack-buffered CNS constant parsing:
cns::parse_constantsunpacks comma-separated numeric vectors into a stack-allocated[f64; 4]array, eliminatingVec<f64>allocations on every constant line. - Pre-allocated command definition vector:
cns::parse_cmdpre-allocatescmdscapacity tosecs.len().
Single-op bytecode fast-path & stack-less expression evaluation
- Single-op expression short-circuit: In
bytecode::Code::run, expressions with exactly one opcode (Op::Const(v),Op::Trig0(i),Op::Host(i)) return immediately without stack array zeroing, program counter advancement, or loop dispatch. - Zero-cost constant and parameter lookups: Constant numbers and 0-argument triggers (
Time,StateTime,AnimTime,StateNo, etc.) execute in 1 CPU cycle, avoiding VM frame setup.
Single-lookup animation advance & target cleanup early continue
-
Single-lookup animation frame unpack in
advance_anim: Unpacks(total, loop_start, len, ft)in a single tuple query onself.anim(), eliminating repeated HashMap lookups per animated fighter and explod each tick. -
Empty size-override short-circuit:
fighter::cimmediately queries character constants whenself.size_overrides.is_empty(), bypassing linear slice scans. -
Stale target cleanup early continue:
Match::tickskips target vector moves and retain passes wheneverself.fighters[k].targets.is_empty(). -
Wave 42 - Fast-Path Palette Effects, Stack Frame Buffers & Zero-Alloc Sctrl Queries:
- PalParams::apply: Fast-path bypass for identity and non-hue/non-inverted color transformations, skipping trigonometry and unrolling color channels.
- PalFx::from_controller: Zero heap allocations for controller parameter lookups using stack-buffered keys.
- Match::tick: Eliminated per-tick Vec
allocations for waken and ag_requests by using stack-allocated fixed arrays, and fused filter/decrement loops with etain_mut.
-
Wave 43 - Zero-Alloc Character Loader Path & In-Place Unquote:
ini::unquote_str: In-place slice borrowing without allocating newStringinstances for unquoted and clean strings.loader::load_mugen_char: Convertedfgetfrom returningOption<String>toOption<&str>, eliminating ~20 heap allocations per character load.loader::local_size: Stack-based parsing viasplit_once(',')replacing dynamicnumsallocation.cns::parse_cmd: In-placeunquote_strfor command name and inputs.
-
Wave 44 - Zero-Alloc AssignKind State Dispatch & Case-Insensitive Bitmasks:
matchs::AssignKind: Replaced dynamicStringallocations in trigger variable assignments with a 1-byte enumAssignKind, cutting assignment tuple memory by 50% and eliminating per-assignment heap operations.hitdef::state_mask/attr_kind_mask/guardflag_bits: In-place case-insensitive ASCII byte folding without string allocations.triggers::const_val: Zero-alloc stack-buffered key lookup forvelocity.*.xconstants.
-
Wave 45 - Explod Cache Array & Projectile Triangular Collision Sweeps:
Match::update_explods: Pre-indexed fighter position and pause states into a compact 8-element stack array, avoiding linearFighterscans per explod.Match::update_projectiles: Stack-buffered frozen flags for up to 64 projectiles avoiding heap allocations, and triangular pair-wise collision iteration(a + 1)..nhalving projectile collision checks.
-
Wave 46 - Collision Box Fast Path & Pre-Scaled Box Geometry:
Fighter::boxes: Early exit for empty collision box lists before computing constants or scale factors (drastically cuts idle/movement frame work).- Pre-scaled X and Y dimensions (
sx * sandsy * s), cutting per-box floating-point multiplications from 8 to 4. - Combined
flip_h != (facing < 0.0)into a single branchless boolean XOR condition. Fighter::c: Guarded slice search with!self.size_overrides.is_empty().
-
Wave 47 - Stack-Buffered VFS Candidate Joining & Zero-Alloc Suffix Matching:
vfs::resolve: Inlinedwith_joinedusing a 512-byte stack buffer forbase_dir/nameanddata/namepath candidates, completely eliminating candidate heap allocations on the direct hit path.- Replaced
format!("/{base}")heap strings with in-place byte boundary predicateis_match. - Used
ini::unquote_strdirectly instead of allocating ownedunquotestrings. - Sub-microsecond VFS folder fallback on 50k files (0.9 us/op) and reduced character load time (
kfm.defdown to 6.7 ms).
-
Wave 48 - Zero-Alloc HUD Frame Pipeline & Direct Texture Quads:
Hud::draw: Streamlinedmain_ofinto single-pass iterator scans avoiding dynamicVec<&Fighter>allocations per side.- Used fixed stack array
roots = [r0, r1]instead of dynamically allocated vectors. - Bypassed partner vector allocations on standard 1v1 matches.
- Replaced temporary mesh/vertex/index heap vectors in portrait drawing with direct
draw_texture_exquad draws.
-
Wave 49 - Dual-Op Bytecode Short-Circuits & Single-Context Trigger Loops:
bytecode::Code::run: Fast-path short-circuit execution for 2-op expressions (!trigger,-const,!const,!host), bypassing stack array zeroing and interpreter loop.Match::triggered: Reused singleCtxacrosstrigger_alland trigger groups, eliminating redundant host context creations per controller evaluation.Match::num: Direct expression evaluation avoiding intermediate Option closure mapping.
-
Wave 50 - SND Pre-Allocation, Deduped State Parsing & Zero-Alloc Command Filters:
snd::decode_snd_checked: Pre-allocated sound dictionary and offset visited sets using the header sound count, with in-placeEntry::Vacantinsertions avoiding redundant sound re-allocation.loader::load_mugen_char: Eliminated redundant second parse pass ofstcommonduring character loading.- Pre-allocated static palette keys
PAL_KEYSto avoid 12 dynamic string formatting allocations per character load. - Pre-allocated capacity for
HashSet,sprites,indexed, andcountsbased on decoded SFF sprite lengths. - Case-insensitive ASCII byte comparison (
eq_ignore_ascii_case) forai_commandsandmovelistfilters, eliminating temporary heap strings for command names. loader::load_mugen_portrait: In-place string slice extraction from section lookups avoiding owned string clones.
-
Wave 51 - Cached Common Sizes, Single-Pass Sprite Lookups & Direct Texture Dispatch:
CharDef: Cached core dimensions and scale factors (scale_x,scale_y,size_ground_back,size_ground_front,size_air_back,size_air_front,size_height,size_attack_dist) directly on the struct viarefresh_sizes.Fighter::c: Fast-path pattern match onsize.*keys avoiding dynamic string hashing andHashMaplookups on every physics, collision, and trigger query.Gfx::sprite_tex_for: Eliminated duplicatedef.sprites.getlookup per rendered frame across all fighters, shadows, helpers, and explods.Gfx::draw_sprite: Usesdef.scale_xanddef.scale_ydirectly, removing repeated per-framedef.c(...)table probes.- Reduced
kfm.defload time to 4.6 ms and accelerated simulation tick rate to 216k ticks/s.
-
Wave 52 - Cached Animation Timing & 3-Op Bytecode Fast-Paths:
Fighter: Cachedanim_total_timeandanim_loop_startupon animation switches, turninganim_time_trig(animtime) into a direct scalar subtraction without map lookups.Fighter::advance_anim: Reused single animation lookup across the frame advance loop and eliminated repeatedself.anim()lookups.Fighter::anim_elem_time: Instant return foranimelemtime(1)without frame iteration.bytecode::Code::run: Fast-path short-circuits for 3-op comparison expressions ([Trig0, Const, Cmp]and[Const, Trig0, Cmp]), evaluating triggers directly viaHost::trigger0and bypassing virtual machine stack allocation.- Dropped
kfm720.defloading time to 8.7 ms andkfm.defto 4.4 ms.
-
Wave 53 - Fighter Index Hints, Stack-Allocated Hits & Early Reversal Bypasses:
Match::idx_hint: Direct $O(1)$ index resolution based on run-order position hints, replacing linear scans across active fighters in the per-tick execution pipeline.Match::detect_reversals: Fast-path early exit when no fighters have an active reversal state, plus fixed-size stack arrays for detected reversals.Match::detect_hits: Stack-allocated fixed bufferpendingstoring only fighter indices and coordinates, avoiding eagerHitDefDataheap clones on idle/no-hit frames.strucklist switched to stack arrays, eliminating vector allocations across physics and hit detection loops.
-
Wave 54 - Stack-Buffered Target Indices & Direct Param Expression Evaluations:
controllers::target_indices: Replaced heap-allocatedVec<usize>with fixed stack array[Option<usize>; 8], eliminating allocation churn inTargetState,TargetLifeAdd,TargetPowerAdd,TargetFacing, andTargetBind.controllers::set_vars: Directly evaluatedparam.exprs.first()without duplicatesc.param(...)string search iterations.controllers::run: Replaced double parameter checks inchangestate/selfstatewith unifiedopt(...)queries forctrlandanim.- Pushed simulation throughput to 226,415 ticks/s with p50 at 0.003 ms, and dropped portrait decode to 0.6 ms.
-
Wave 55 - Aligned u32 RGBA Decoding, Pre-Allocated SFF Tables & Branchless PCX Palettes:
- sff::sprite_to_rgba: Allocated direct Vec
ensuring guaranteed 4-byte hardware alignment, eliminating slice-alignment fallback loops and branch checks, and converting to Vec via zero-cost Vec::from_raw_parts. - pcx::read_rgb_palette: Converted 768-byte RGB chunks to [u32; 256] with branchless u32::from_ne_bytes and constant alpha assignments, dropping byte-by-byte shifting.
- sff::decode_v1: Removed unused idx from V1Job and pre-allocated jobs buffer with count.min(8192).
- sff::decode_v2: Pre-allocated palettes buffer with pal_count.min(buf.len() / 16 + 1) and jobs buffer with spr_count.min(buf.len() / 28 + 1).
- sff::decode_v2_image: Optimized RAW depth-32 frames with single slice copies and depth-24 frames with 3-byte chunks instead of byte-by-byte offset probing.
- sff::sprite_to_rgba: Allocated direct Vec
-
Wave 56 - Copy-Derived Binds, Lazy Fallbacks & Direct In-Place State Animations:
fighter::Bind: DerivedCopyandPartialEq, turning bind checks and updates inrebindandupdate_bindinto direct stack bit-copies with zero heap cloning.fighter::Fighter::change_anim_own: Added internal animation change helper from own definition, removing externaldef.clone()overhead inchangestate,changeanim, and auto-turn transitions.matchs::run_state: Convertedcommonlookup into a lazy fallback (let fallback;), bypassingself.common.clone()on all negative states (-3, -2, -1) and every character-defined state.matchs::change_state: Replaced eagerself.common.clone()with reference pointer equality&self.commonand lazy state definition fallback.matchs::tick: Replaced per-framef.st_def.clone()in physics override loop with scalarOption<char>extraction.
-
Wave 57 - Non-Allocating INI Parsing, Pre-Allocated Controllers & State Sizing:
ini::parse_ini_no_lines: Replaced line-allocating INI parsing inparse_states,parse_constants,parse_cmd, andloader.rscharacter DEF resolution withparse_ini_no_lines, avoiding tens of thousands of unusedStringline allocations per character.ini::parse_ini_opt: Pre-allocated section output vector withtext.len() / 256 + 4and section entries with capacity 8.cns::build_controller: Pre-allocated controllerparamswith capacity matchings.entries.len().cns::parse_states: Pre-allocatedStateDefwithcontrollerscapacity 16 andparamscapacity matching section entries, eliminating dynamic reallocation during state compilation.
-
Wave 58 - Stack-Buffered Path Normalization, Fast Command Short-Circuits & Copy Symbols:
vfs::with_norm_path: Stack-allocated 512-byte buffer for path normalization and unquoting, eliminating heap allocation across all resource lookups invfs::resolve.commands::CmdSymbol: DerivedCopyandPartialEqfor 20-byte bitwise symbol handling.commands::held: Early button bitmask check before invoking relative direction and facing lookups, short-circuiting inactive buttons on the first instruction.commands::fires: Evaluatednow & !prevbefore reading older history ticks (p2,p3), skipping multi-tick history probes on non-firing frames.
-
Wave 59 - Cached Scale in Box Filling & Multi-Box AABB Collision Pruning:
fighter::fill_boxes: Bypassed dynamicsize.*string queries when no size overrides exist, readingdef.scale_xanddef.scale_ydirectly.matchs::overlap: Added composite axis-aligned bounding box early exit when checking multi-box collision groups (a.len() > 1 || b.len() > 1), eliminating $O(N imes M)$ pairwise tests on disjoint collision clusters.
-
Wave 60 - Zero-Alloc AIR Frame Tokenization & Pre-Sized Animation Buffers:
air::parse_air: Replaced per-frameVec<&str>heap allocation with a fixed 12-element stack array[""; 12], eliminating dynamic vector allocations across all animation frames.air::parse_air: Replacedto_ascii_uppercase()String allocations for flags and blend modes with zero-alloc byte-level inspection (fl.as_bytes(),bl.as_bytes()).air::parse_as_d: Replaced string searching with case-insensitive byte scanning forAS...D...alpha parameters.air::parse_air: Pre-allocated animation frames vector withVec::with_capacity(8)and the animation HashMap withtext.len() / 512 + 16.
-
Wave 61 - Dedicated Zero-Arg Trigger Dispatch & Byte-Level String Comparison:
triggers::trigger0: Fast-pathed the top 20 zero-argument triggers (time,animtime,stateno,prevstateno,anim,ctrl,alive,life,facing,roundstate,movecontact,movehit,vel,pos) directly without argument-closure setup or the 90-arm general match.triggers::cmpstr: Switched string character decoding to single-byte inspection (v0.as_bytes().first()) forstatetype,movetype, andphysics, and reused parsed string slice incommandchecks.
-
Wave 62 - Bytecode VM Fast Paths for 1-Arg Triggers & Arithmetic Comparisons:
bytecode::Code::run: Added dedicated fast paths for 2-op unary 1-arg triggers ([Op::Const, Op::Trig1]), 3-op inverted 1-arg triggers ([Op::Const, Op::Trig1, Op::Not]), and 4-op 1-arg trigger comparisons ([Op::Const, Op::Trig1, Op::Const, Op]), bypassing the stack machine loop and vector indexing forvar(X) = Y,fvar(X) > Y, andanimelemtime(X) >= Y.bytecode::Code::run: Expanded 3-op comparisons to cover arithmetic (Add,Sub) and trigger-to-trigger relational checks ([Op::Trig0, Op::Trig0, Op]), eliminating stack interpreter overhead for expressions likeanim = statenoortime > animtime.
-
Wave 63 - Lazy SND Cycle Detection & Zero-Alloc FNT Glyph Tokenization:
snd::decode_snd_checked: Replaced eagerHashSet<usize>allocation per SND file with lazy initialization (Option<HashSet<usize>>) triggered only when subfile offsets point backwards (next <= ofs), eliminating heap allocation and hashing overhead across all standard sequential SND files.fnt::decode_fnt_v1: Replaced per-glyph linesplit_whitespace().collect::<Vec<&str>>()heap allocations with a streaming iterator reading up to 3 tokens directly, eliminating hundreds of vector allocations per font file.fnt::decode_fnt_v2: Switched font descriptor parsing toparse_ini_no_lines, avoiding unusedlines: Vec<String>collection.
-
Wave 64 - Zero-Alloc Command Charge Parsing & Pointer-Guarded Animation Switching:
commands::parse_command: ReplacedStringheap collection in release/charge command prefix parsing (~30) with zero-alloc byte slice indexing and ASCII byte matching for prefix symbols (/,$,>,~).fighter::change_anim: AddedArc::ptr_eqguard avoiding reference count bumps whenfromis already the activeanim_def.fighter::change_anim_own: Switched to direct immutable reference borrowing ofself.defwithout cloning theArc<CharDef>atomic counter.
-
Web select screen (
scripts/web-frame-probe.js,scripts/web-profile.js):- Native roster tiles draw
portrait.pngthroughCharEntry::tile_portrait(one small PNG decode, cached per pack revision) instead of compiling an idle+win preview per tile; the full preview is only built for the focused or picked fighter. - Previews wait until the fighter's sprite pack has arrived (
CharEntry::tile_art_ready), so no placeholder art is drawn while the pack downloads. - On
wasm32a fighter whose pack is missing previews only the first frame of each menu animation, and the automatic art resolution is capped at 3.0 (the effect rasterizer is single-threaded there). Recolor::apply_in_regionuses a multiplicative hasher and a last-colour memo instead of SipHash per pixel.- The sprite pack cache holds 64 packs, so rosters above 24 fighters no longer evict each other.
- Measured with the profiler in headless Chromium (select screen, 53 cursor moves): main-thread busy time dropped from about 98 s to about 2.5 s.
- Native roster tiles draw
Sprite-sheet effects
src/vfx/sheet.rs plays CC0 effect sheets from assets/fx/ (embedded with include_bytes!, decoded and uploaded on first draw). A hit spark plays on every non-guarded hit; an explosion plays on hits of 150 damage or more and on KO. At most 12 sheet sprites are alive, drawn with additive blending, and they are cleared on round start. Pixel-art PVFX Foundry sheets (nearest filter, alpha blend) add punch hit on light hits, crit hit on heavy hits, shockwave ring and ground slam on 150+ damage grounded hits, parry on guarded hits and dash dust on dashes. Lightning strike and static burst play on supers, a fire pillar on transformations, a smoke bomb on KO and a frost nova on heavy guarded hits. Sheets and credits are listed in assets/fx/CREDITS.md.
Parallel variant sprite raster
Compiling a UMF fighter rasterized the base frames in parallel and then recolored every form and awakening variant of every frame on one thread, which was 80 to 90% of the load. native/frame_raster.rs now renders each frame together with its variants inside the same worker pool (min(cores, 8), one thread on wasm32), and the form palettes are built once per fighter instead of once per frame.
cargo run --release -p ume-engine --example load_bench on the 4-core cloud machine, three runs each:
| Whole roster (21 fighters) | Oboro | Kaito | Suzume | |
|---|---|---|---|---|
| Before | 11.40 / 11.76 / 11.79 s | 1674 ms | 1250 ms | 900 ms |
| After | 4.70 / 4.46 / 4.54 s | 551 ms | 405 ms | 319 ms |
The output is unchanged: a checksum of every sprite (pixels, size, axis, scale) and every animation frame of the 21 fighters in two palettes is identical before and after. Fighters without forms (npc_*) do not change, since they have no variants to render.
Graphics presets for slow machines
Settings, tab PERFORMANCE: one preset (High, Medium, Low, Minimum, or Custom once any option differs) plus individual options. Everything is visual only; Match::tick, rollback and replays never read these values.
| Option | High | Medium | Low | Minimum |
|---|---|---|---|---|
| Render scale (fight scene, HUD stays sharp; also 35% and 25% by hand) | 100% | 100% | 75% | 50% |
Post-processing (fx) | High | Medium | Off | Off |
| Particles and effects | Full | Reduced | Reduced | Minimal |
| After image, glass HUD, animated backdrop, CRT | on | on (CRT off) | off | off |
| Shadows | on | on | on | off |
- Render scale draws the scene into a smaller target and the post pass upsamples it to the window (
ume_shell::quad::set_render_scale,PostFx::scene_view). With post-processing off and scale below 100% a neutral post pass is still used. - Runtime flags live in
src/lite/flags.rs; render code readscrate::lite::shadows(),afterimage(),backdrop(),glass(),crt(). - Auto adjust (default on for the web build):
lite::Monitoraverages frame time over 4 s of fight after a 3 s warm-up; above 24 ms it moves one preset lighter, saves the settings and shows a toast. It never raises quality again by itself. - Measure with
UME_PRESET=0..3 UME_TOUR=perf(desktop) or the?e2e=1&modo=watchmatch in Chromium (web).
Measured on the 4-core cloud machine with software rendering (lavapipe for desktop, SwiftShader for web, 1280x720, Kaito vs Shion):
| Preset | Desktop frame avg | Web fps |
|---|---|---|
| High | 28.7 ms | 10.5 |
| Medium | 28.9 ms | 11.5 |
| Low | 19.5 ms | 18.7 |
| Minimum | 15.8 ms | 21.8 |
Low window resolutions
Settings, VIDEO tab (desktop): window resolution now starts at 640x360, then 854x480, 960x540, 1024x576, 1280x720 and up to 5K. The cfg stores res_px=WxH; old res=<index> files are migrated to the same size. Picking a resolution clears the remembered window size so the choice always applies. On web and mobile the window follows the page, so use Render scale (down to 25%) instead.
Desktop, software rendering, perf tour (Kaito vs Shion): 1280x720 31.5 ms, 854x480 15.1 ms, 640x360 10.5 ms per frame. Web render scale 50% / 35% / 25%: 21.5 / 22.0 / 23.4 fps (CPU bound below 50%).