Performance "Physics" und "Editor" #284

Closed
opened 2026-09-30 22:21:26 +02:00 by admin · 1 comment

Als Referenz das Projekt cbbf160bb7e8 checken. hier noch eine Momentaaufnahme vom Performance Panel:
image.png

Wenn ich zur Laufzeit Crates und Tilemap destroye - folgende Werte:
image.png

Wenn ich zusätlich noch "UI - Window" und das Inventory Behaviour destroye:
image.png

Player selbst nimmt auch einen Einfluss. Frage ist ob man da noch was optimieren könnte.

Als Referenz das Projekt `cbbf160bb7e8` checken. hier noch eine Momentaaufnahme vom Performance Panel: <img width="206" alt="image.png" src="attachments/4ee0c642-cd5c-452d-a388-48d81c22806d"> Wenn ich zur Laufzeit Crates und Tilemap destroye - folgende Werte: <img width="260" alt="image.png" src="attachments/7847f236-f8ca-4dbd-96cd-11bb8ea19537"> Wenn ich zusätlich noch "UI - Window" und das Inventory Behaviour destroye: <img width="218" alt="image.png" src="attachments/cfd946e5-94b6-4089-8043-27ca6d0fa130"> Player selbst nimmt auch einen Einfluss. Frage ist ob man da noch was optimieren könnte.
admin added this to the Development project 2026-09-30 22:21:26 +02:00
admin moved this to Next in Development on 2026-09-30 22:21:31 +02:00
admin added the question label 2026-09-30 22:21:53 +02:00
Owner

Done in cfd288c, wiki c8cc9cd (Tilemaps, Development).

Yes, there was a good deal left. A frame of the reference project in Play now takes less than half the time on the main thread.

Measured
Project cbbf160bb7e8, "Demo scene", 222 entities, played as a copy in the e2e account on stein2 (about 1.7 times slower than the machine of the screenshots, the proportions match them). Values of the performance panel in ms per frame:

before after without map and crates (after)
Physics 2.64 0.97 0.30
Drawing 6.89 2.56 1.63
Editor 1.95 1.31 0.98
Sum of all five areas 12.3 5.7 3.4
Possible 81 fps about 175 fps

Single values move by a few tenths of a ms between two runs.

What it was
Nearly all of it hung on the tilemap, which only stands there:

  • Comparing cells (largest item, 14 percent of the run): the physics and the drawing compared the content of all cells on every question, about 60 times a frame. Now the writer says so with cellsChanged, and only then are the cells compared. There are exactly four writers: the brush during a stroke and at its end, PaintTilesCommand on execute and on undo.
  • Drawing twice: with an animated tile in view (the water) the game view was drawn twice a frame, once by the run and once by animate(). The second one is gone.
  • Geometry: every mesh of the map was built anew with each drawing. Now only when the cells, the tile size or the picture change, so for the water once per animation step.
  • Physics: each tick went through every collider of the map. An unchanged map is skipped.
  • Editor: syncToModel searched the entity list and the asset list per object (quadratic). Now there is one map per pass.

What is left

  • Editor depends on the number of entities. syncToModel still mirrors every object into the model every frame. The 162 entities of the closed inventory window cost 0.98 instead of 0.22 ms that way, although they are not drawn. That is #287.
  • The player: nothing stood out. Behaviors are at 0.4 to 0.8 ms, Move against the map at about 0.2 ms.

Tests (on melektaus-atx)

gate                      198 files, 2887 tests, CHECK EXIT 0 (2883 + 4)
e2e 1-17,28,33,39-43,59   ALL PASSED - 810 checks
smokes                    24 / 19 / 21, SMOKES EXIT 0
  • Three new e2e checks in module 40: the stroke shows while the button is held, a frame in Play draws the game view once (40 frames, 40 redraws), and meshes are not rebuilt with every drawing (8 builds in 40 frames).
  • Three unit tests wrote cells directly and now call cellsChanged. That is the change of contract: a new writer that forgets it stays invisible.
  • Eleven counter-checks, all work in the end. Two did not at first: the stroke had no check of its own, and the physics test had to start with the map switched off. That last one was repeated on stein2 only, not in the container.
  • Screenshot of the running project checked: map, hills, crates and player are right. Whether the water moves cannot be seen at 25 % zoom, e2e 40e checks that.
  • The e2e total of 1613 is computed (1610 + 3). CI is still switched off, so there is no run for cfd288c.
Done in `cfd288c`, wiki `c8cc9cd` (*Tilemaps*, *Development*). Yes, there was a good deal left. A frame of the reference project in Play now takes less than half the time on the main thread. **Measured** Project `cbbf160bb7e8`, "Demo scene", 222 entities, played as a copy in the `e2e` account on stein2 (about 1.7 times slower than the machine of the screenshots, the proportions match them). Values of the performance panel in ms per frame: | | before | after | without map and crates (after) | |---|---|---|---| | Physics | 2.64 | 0.97 | 0.30 | | Drawing | 6.89 | 2.56 | 1.63 | | Editor | 1.95 | 1.31 | 0.98 | | Sum of all five areas | 12.3 | 5.7 | 3.4 | | Possible | 81 fps | about 175 fps | | Single values move by a few tenths of a ms between two runs. **What it was** Nearly all of it hung on the tilemap, which only stands there: - **Comparing cells** (largest item, 14 percent of the run): the physics and the drawing compared the content of all cells on every question, about 60 times a frame. Now the writer says so with `cellsChanged`, and only then are the cells compared. There are exactly four writers: the brush during a stroke and at its end, `PaintTilesCommand` on execute and on undo. - **Drawing twice**: with an animated tile in view (the water) the game view was drawn twice a frame, once by the run and once by `animate()`. The second one is gone. - **Geometry**: every mesh of the map was built anew with each drawing. Now only when the cells, the tile size or the picture change, so for the water once per animation step. - **Physics**: each tick went through every collider of the map. An unchanged map is skipped. - **Editor**: `syncToModel` searched the entity list and the asset list per object (quadratic). Now there is one map per pass. **What is left** - **Editor depends on the number of entities.** `syncToModel` still mirrors every object into the model every frame. The 162 entities of the closed inventory window cost 0.98 instead of 0.22 ms that way, although they are not drawn. That is #287. - **The player**: nothing stood out. Behaviors are at 0.4 to 0.8 ms, `Move` against the map at about 0.2 ms. **Tests** (on `melektaus-atx`) ``` gate 198 files, 2887 tests, CHECK EXIT 0 (2883 + 4) e2e 1-17,28,33,39-43,59 ALL PASSED - 810 checks smokes 24 / 19 / 21, SMOKES EXIT 0 ``` - Three new e2e checks in module 40: the stroke shows while the button is held, a frame in Play draws the game view once (40 frames, 40 redraws), and meshes are not rebuilt with every drawing (8 builds in 40 frames). - Three unit tests wrote cells directly and now call `cellsChanged`. That is the change of contract: a new writer that forgets it stays invisible. - Eleven counter-checks, all work in the end. Two did not at first: the stroke had no check of its own, and the physics test had to start with the map switched off. That last one was repeated on stein2 only, not in the container. - Screenshot of the running project checked: map, hills, crates and player are right. Whether the water moves cannot be seen at 25 % zoom, e2e 40e checks that. - The e2e total of 1613 is computed (1610 + 3). CI is still switched off, so there is no run for `cfd288c`.
admin moved this to Done in Development on 2026-10-01 09:59:13 +02:00
admin removed the question label 2026-10-03 19:44:09 +02:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: meleki/feuerwerk#284