chore: Add benchmarks covering the component tree hot paths#3959
Merged
Conversation
- flame@1.38.0 - flame_3d@0.3.0 - flame_behaviors@1.4.0 - flame_bloc@1.12.24 - flame_steering_behaviors@0.2.2+6 - flame_test@2.3.0 - flame_tiled@3.1.2 - flame_behavior_tree@0.1.5+5 - flame_gamepads@0.1.2 - flame_isolate@0.6.3+23 - flame_texturepacker@5.1.2 - flame_sprite_fusion@0.2.4+2 - flame_fire_atlas@1.8.18 - flame_audio@2.12.2 - flame_spine@0.3.1+6 - flame_kenney_xml@0.1.3+2 - flame_lottie@0.4.3+23 - flame_markdown@0.2.5+16 - flame_console@0.1.4 - flame_rive@1.11.2 - flame_forge2d@0.19.3+7 - flame_noise@0.3.3+23 - flame_riverpod@5.5.5 - flame_svg@1.12.2 - flame_typled@0.1.2 - flame_network_assets@0.3.4+23
erickzanardo
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds the benchmark coverage needed to evaluate new component tree implementations (#3957), so that every phase of that work can be measured against a locked-in baseline.
New suites
children_traversal_benchmark.dart: pure update-pass and render-pass overhead (container iteration,updateTree/renderTreerecursion) over no-op components in four tree shapes: wide (10k x 1), nested (1k x 10), deep (100 levels), and a barrier tree where every 10th parent overridesupdateTreeviaHasTimeScale. The barrier variant exists because effects, routes, and time-scaled components manage their own subtree traversal, so it is the realistic go/no-go input for flattened-traversal designs.component_churn_benchmark.dart: steady-state add/remove churn (100 components per tick through the lifecycle queue) at both 1k and 10k populations, plus bulk 1k add/remove cycles. The 10k variant exists because removal cost inside one large sibling container scales differently per container implementation.priority_change_benchmark.dart: single-child priority changes across 100 parents (today a full sibling rebalance each), and the y-sort pattern where all 1000 children of one container are re-prioritized every tick. Random sequences are precomputed insetupso everyrun()does identical work.type_query_benchmark.dart: maintenance and read cost of theregister<T>()/query<T>()type-query caches under mixed-type churn, since any container replacement must keep that surface.common.dart: amountGamehelper that brings aFlameGameto a properly loaded and mounted state without aGameWidget.README.md: how to run the suite, what each file measures, and pitfalls when writing new benchmarks.Fixes to existing benchmarks
update_components_benchmark.dartnever calledonGameResize/load/mount, sohasLayoutwas false,onLoadnever ran, and the intended 10 children per component were never created: it silently measured a flat tree of ~1000 empty components (11x smaller than intended) with the lifecycle queue bypassed. It now mounts properly; ticks were reduced from 2000 to 500 (same input density) so the harness gets ~12 samples per measurement window instead of ~3.render_components_benchmark.dartnow also mounts properly, and both older files got a top-levelmainso they can be run standalone.main.dartnow runs every suite in the directory, including the previously unwired hit-testing and collision benchmarks.Baseline on a desktop machine (JIT, asserts on, relative comparison only)
Not covered here and left as follow-up: a GC/allocation-rate measurement (needs a different harness than benchmark_harness) and on-device AOT runs, which is how go/no-go numbers for #3957 should be collected (
flutter run --release -t benchmark/main.dart).Checklist
docsand added dartdoc comments with///.examplesordocs.Breaking Change?
Related Issues
Related to #3957