-
Notifications
You must be signed in to change notification settings - Fork 6k
Use Float32List as Matrix storage inside the Web engine #17856
Conversation
@@ -7,6 +7,19 @@ part of engine; | |||
|
|||
typedef OnBenchmark = void Function(String name, num value); | |||
|
|||
typedef Action<R> = R Function(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you intend to have profiler.dart change in this PR ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will remove it once I rebase on top of #17852. I will rebase on top of it and remove the profiler changes here. I only needed it to verify the impact of the change on preroll, where we do a ton of vector math.
commitScene(_persistedScene); | ||
_lastFrameScene = _persistedScene; | ||
return SurfaceScene(_persistedScene.rootElement); | ||
timeAction<void>('sceneBuilderPrerollFrame', () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
treeshake from release builds ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find a way to tree-shake timeAction
entirely without making the cost super-ugly. Open to ideas, but currently decided that it wasn't worth it. In release mode timeAction
becomes:
R timeAction<R>(String label, Action<R> action) => action();
So the cost is one closure. Since SceneBuilder.build
runs once per frame the difference is negligible.
This change converts all
Float64List
matrices toFloat32List
at thedart:ui
interface boundary. Internally, it only usesFloat32List
.Float32List
requires less memory and is orders of magnitude faster to allocate, and it has sufficient precision as Flutter mobile engine and Skia use 32-bit floats anyway.This change speeds up frame preroll by 50% on the bench_card_infinite_scroll benchmark.
For more details on
Float64Array
allocation in JS (which backsFloat64List
in Dart) see the following: