Commit 190e95c
committed
fix(perf): keep PerfStress responsive at 250/500 elements
Two complementary fixes for the Reactor.TestApp PerfStress demo, where the
UI froze under sustained high-frequency setState from an async sort loop.
ReactorHost / ReactorHostControl: RequestRender already coalesces concurrent
setStates within one dispatch tick, but only demoted to LOW priority when a
state change happened *during* a render. The PerfStress pattern (setState
between `await Task.Delay` ticks) never hit that path, so renders piled up at
Normal priority and starved input/layout/paint on the same UI thread.
RenderPriorityPolicy now demotes the next TryEnqueue to Low whenever the
previous render exceeded a 16 ms frame budget — same mechanism the
existing in-render path already uses, just extended to the
between-renders path.
PerfStressDemo: each render allocated ~1500 fresh SolidColorBrush instances
at 500 elements (3 per bar × string `.Background("#hex")` overload), and
because every brush had a different reference, UpdateBorder wrote
b.Background unconditionally and WinUI re-painted every border every tick.
A [ThreadStatic] brush cache keyed by color string collapses that to ~16
brushes for the lifetime of the demo and lets the reconciler's reference
check short-circuit the redundant Background writes.
Tests:
- 9 new RenderPriorityPolicyTests pin the priority decisions and the
ReactorHost/ReactorHostControl wiring contract.
- Full unit suite (7534 tests) and selftest suite (689 tests) pass.1 parent c2e27e4 commit 190e95c
5 files changed
Lines changed: 231 additions & 9 deletions
File tree
- samples/Reactor.TestApp/Demos
- src/Reactor/Hosting
- tests/Reactor.Tests/Hosting
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
23 | 50 | | |
24 | 51 | | |
25 | 52 | | |
| |||
233 | 260 | | |
234 | 261 | | |
235 | 262 | | |
236 | | - | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
237 | 267 | | |
238 | 268 | | |
239 | 269 | | |
240 | | - | |
| 270 | + | |
241 | 271 | | |
242 | 272 | | |
243 | 273 | | |
| |||
247 | 277 | | |
248 | 278 | | |
249 | 279 | | |
250 | | - | |
| 280 | + | |
251 | 281 | | |
252 | 282 | | |
253 | 283 | | |
254 | 284 | | |
255 | 285 | | |
256 | 286 | | |
257 | 287 | | |
258 | | - | |
| 288 | + | |
259 | 289 | | |
260 | 290 | | |
261 | 291 | | |
| |||
270 | 300 | | |
271 | 301 | | |
272 | 302 | | |
273 | | - | |
| 303 | + | |
274 | 304 | | |
275 | 305 | | |
276 | 306 | | |
| |||
315 | 345 | | |
316 | 346 | | |
317 | 347 | | |
318 | | - | |
| 348 | + | |
319 | 349 | | |
320 | 350 | | |
321 | 351 | | |
| |||
337 | 367 | | |
338 | 368 | | |
339 | 369 | | |
340 | | - | |
| 370 | + | |
341 | 371 | | |
342 | 372 | | |
343 | 373 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
107 | 113 | | |
108 | 114 | | |
109 | 115 | | |
| |||
480 | 486 | | |
481 | 487 | | |
482 | 488 | | |
483 | | - | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
484 | 497 | | |
485 | 498 | | |
486 | 499 | | |
| |||
717 | 730 | | |
718 | 731 | | |
719 | 732 | | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
720 | 739 | | |
721 | 740 | | |
722 | 741 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
92 | 97 | | |
93 | 98 | | |
94 | 99 | | |
| |||
299 | 304 | | |
300 | 305 | | |
301 | 306 | | |
302 | | - | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
303 | 313 | | |
304 | 314 | | |
305 | 315 | | |
| |||
509 | 519 | | |
510 | 520 | | |
511 | 521 | | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
512 | 525 | | |
513 | 526 | | |
514 | 527 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
Lines changed: 119 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
0 commit comments