Jonah Williams 185f7cc518 [Impeller] when creating new pipeline variant block on current thread, re-persist dirty pipeline cache. (flutter/engine#52375)
Current diagram of how PSO variants are created (after first bootstrap)

```
Raster thread.                             Worker Thread
1.  Check Pipeline Cache
2. Pipeline Cache Empty
3. Create Promise
4. Spawn Worker                     ->      Compile Pipeline
5. Block On Future.                       ..                                                    
6.
7. Resolve                          <-      Complete Future
```

This is a serialized workload due to blocking on future completion. But performing it on two threads means that we're also adding in the somewhat random cost of thread scheduling and or getting deprioritized.

Instead when creating variants, block on the current thread. Now if we knew all the variants we need to create for a frame ahead of time, we could spawn one or more works to creat them more quickly. This would require more work though.

While I'm at it. Update the pipeline cache to persist every 50 frames, if it has added a new shader.

part of https://github.com/flutter/flutter/issues/129660
2024-04-28 17:22:13 +00:00
..