Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@chinmaygarde
Copy link
Member

Copy link
Contributor

@sethladd sethladd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you! mostly style feedback, a few content feedbacks.

@chinmaygarde
Copy link
Member Author

Another pass?

multiple times (on all platforms) to ensure success. Moreover, applications
that were really effective at training began to run into egregiously high
first-frame times ([some as high as 6
seconds](http://github.com/flutter/flutter/issues/97884)).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth mentioning that this never worked at all on Android, due to the fact that skia generated different shaders based on GPU model

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I remembered but got lazy and didn't want to look up the bugs to cross reference here. But flutter/flutter#102655 seems to be it. Still open! Will add.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Also added a ref to things we tried to reduce shader variants.

Impeller are ready well before the Flutter application's Dart isolate is
launched. Skia can generate and compile shaders during frame workloads
leading to worse worst-frame times.
* Because the processing of shaders in Impeller happens at build time when
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a minor nit, we are still compiling shaders at runtime, and may generate new PSOs on demand. But we don't have to go through a source -> source translation or reflection step, and on iOS we can use metal achive files which load much faster.

The GPU is still jitting the shader though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a good thing to mention. Is there a general notion we can give of the relative cost between PSO generation and the source->source translation? Like is it 10x cheaper?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100x maybe?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on iOS in particular, it seems to be closer to "free"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(The PSO generation)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And important to point out this isn't an alternative, in the old route we go source -> source -> metal compiler (source) -> PSO. now we just go metal compiler (archive) -> PSO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went back and forth quite a bit on this and adding backend specific nuance made things a whole lot more complicated. On Metal, we can use either AIR files or the new Metal Binary Archives which really move everything to be at build time. But have to resort to flinging strings around with OpenGL ES. So what happens before GPU microcode is generated is quite quite messy to explain. This seemed like a fine enough bit of context to tell the story. Should I add another FAQ entry perhaps?

@zanderso From go/impeller-prototype, I found this screenshot of a trace I took where the cost of the shader library construction is separate from the PSO creation (the small pink trace at the end). I think in this version of Skia, this included source-to-source translation as well as the shader library construction we do here in Impeller. Even that last bit at the end, Impeller does before first frame (well variants are another matter I suppose).

Screenshot 2024-08-09 at 10 56 02 AM

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, nevermind. In this case, there is an SKSL cache hit. Its even slower when there is no cached SKSL. This used to happen when the phone was rebooted and Metals caches weren't warmed up from previous runs. I was making that case that perfect SKSL caches were necessary but not sufficient for jank free operation because metalc literally had to do LLVM things and that was more than sufficient to blow our frame budgets.

Such a mess and I've blocked away so much of this context in my head.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We, of course, never found this janky behavior on our benchmarks because we didn't reboot phones between runs to clear the internal metal caches.

Copy link
Contributor

@sethladd sethladd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comments

LGTM thank you!

* How do you run `impeller_unittests` with Playgrounds enabled?
* Specify the `--enable_playground` command-line option.
* Describe Impeller in a Tweet.
* "Impeller is AOT mode for rendering."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spell out AOT. Suggest "Ahead of Time (AOT) mode ..."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also mention what is being AOT'ed? Like "Impeller is rendering with ahead-of-time (AOT) compilation"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seths suggestion done. Michael, that should become clearer in the next entry. Should I add another FAQ entry perhaps?

as development progresses.
* How do you run `impeller_unittests` with Playgrounds enabled?
* Specify the `--enable_playground` command-line option.
* Describe Impeller in a Tweet.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest s/Describe Impeller in a Tweet/Describe Impeller in less than 10 words/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But thats literally what Seth asked 😄 !

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hah yes I did, but I like @mit-mit 's suggestion here :)

* How do you run `impeller_unittests` with Playgrounds enabled?
* Specify the `--enable_playground` command-line option.
* Describe Impeller in a Tweet.
* "Impeller is AOT mode for rendering."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also mention what is being AOT'ed? Like "Impeller is rendering with ahead-of-time (AOT) compilation"?

with Skia after years of effort by graphics experts. The longer answer...
* Flutter applications, via their use of Skia, were susceptible to the problem
of jank (user-perceptible stuttering/choppiness in animations and
interactions) due to shader compilation. Such problems were [reported as
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe s/due to shader compilation/due to needing rendering shaders to be compiled on-demand before they could be executed/ or similar?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good clarification

* Why did the Flutter team build Impeller?
* The short answer, for consistent performance, which could not be achieved
with Skia after years of effort by graphics experts. The longer answer...
* Flutter applications, via their use of Skia, were susceptible to the problem
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The longer form answer here reads a bit odd in bullet form. Usually bullets are separate points, but here it's just a set of paragraphs. Could it be reformatted to a single large bullet with text and line breaks?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, @sethladd mentioned the same thing thing in #54456 (comment). I'm going to reformat the entire doc in a later patch.

@mit-mit
Copy link
Member

mit-mit commented Aug 9, 2024

One high-level question: Wouldn't it be better to add this to the official FAQ on https://docs.flutter.dev/resources/faq ?

@chinmaygarde
Copy link
Member Author

Wouldn't it be better to add this to the official FAQ

This FAQ contains things that are not user-facing in any way. So I'm not sure if that will just cause confusion. Specific entries maybe? I can duplicate those if you tell me which ones.

@chinmaygarde
Copy link
Member Author

I'm landing what I have. All comments have been addressed. Happy to followup with fixes and additions as necessary.

@chinmaygarde chinmaygarde added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 9, 2024
@auto-submit auto-submit bot merged commit 2f577d8 into flutter:main Aug 9, 2024
@chinmaygarde chinmaygarde deleted the morefaq branch August 9, 2024 19:44
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 9, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Aug 9, 2024
@sethladd
Copy link
Contributor

Wouldn't it be better to add this to the official FAQ

Good call @mit-mit , I think we can add one question to the official faq [1] under "Technology" for "What rendering engine does Flutter use?" and give a quick answer there, and then link out to the fuller Impeller FAQ.

Note that https://docs.flutter.dev/resources/faq does mention Impeller, which is good.

WDYT?

[1] https://docs.flutter.dev/resources/faq

@tvolkert
Copy link
Contributor

I think it might be useful to add a "But if Impeller suits Flutter's use cases more, what use cases is Skia optimized for?" question, where we can talk about how Skia's compiled shaders are shared across websites and tabs (in Chrome) and across apps (when built into Android), so the cost gets amortized and thus isn't paid by every app (the way it is for Flutter). And we can also give a shout out to Skia for having better best-cases frame times -- i.e. higher throughput vs more predictable rendering.

Thoughts?

@tvolkert
Copy link
Contributor

It also might be worth addressing the question "Is the Graphite project Skia's answer to Impeller, and does it obviate Impeller?"

@jonahwilliams
Copy link
Contributor

Skia doesn't have better frame times on iOS though :)

@chinmaygarde
Copy link
Member Author

having better best-cases frame times -- i.e. higher throughput vs more predictable rendering.

This was considered to be an acceptable tradeoff when Impeller was first prototyped. And it was the case in early 2023. But Impeller now has higher throughput as well lower memory usage in most of our benchmarks (attached below). There are obviously edge cases we keep discovering on an ongoing basis. There is a lot more work to do but we intend to beat benchmarks for those edge cases as well. I'd rather not feign modesty about Impellers throughput but acknowledge our work is not done yet.

Some of the questions around Graphite are speculative but I've attempted to answer these in go/impeller-faq-followups. Happy to move these over to the FAQ when the open questions are answered.

Throughput
Screenshot 2024-08-12 at 1 55 29 PM

Memory
Screenshot 2024-08-12 at 1 55 38 PM

DBowen33 pushed a commit to DBowen33/flutter that referenced this pull request Aug 16, 2024
Buchimi pushed a commit to Buchimi/flutter that referenced this pull request Sep 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App e: impeller

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Impeller] Add FAQ entries.

6 participants