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

Replace LinkedLists that are used as a queue in android FlutterRenderer with ArrayDeques #51494

Merged
merged 3 commits into from
Apr 17, 2024

Conversation

gmackall
Copy link
Member

@gmackall gmackall commented Mar 18, 2024

Inspired by #50767.

As their documentation notes, ArrayDeques are generally faster than LinkedList when used as a queue.

Fixes flutter/flutter#143721

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@jonahwilliams
Copy link
Member

I have some notes on benchmarking Android CPU times in https://github.com/flutter/engine/blob/main/impeller/docs/android_cpu_profile.md

As long as it is faster locally I'd consider an NTE

@gmackall
Copy link
Member Author

I have some notes on benchmarking Android CPU times in https://github.com/flutter/engine/blob/main/impeller/docs/android_cpu_profile.md

As long as it is faster locally I'd consider an NTE

Thanks, I got the benchmarking working. Can I ask what app you were benchmarking in flutter/flutter#143721? It looks like in another issue you referenced it being the gallery, but I see we have both
https://github.com/flutter/gallery
and
https://github.com/flutter/flutter/tree/master/dev/integration_tests/flutter_gallery
The first one fails to ever launch for me, while the second one has a bunch of problems when I try to run with --enable-impeller on my emulator. Maybe I need to run it on a device?

@jonahwilliams
Copy link
Member

This isn't really impeller specific, you should be able to see this with the Skia backend too. Never benchmark on an emulator, you should always use a real device.

@johnmccutchan has a fullscreen webview example I was using, I don't have a link to it, but any platform view that continually pumps frames should work.

@gmackall
Copy link
Member Author

I finally got around to testing this, (tested this with the video player plugin on @matanlurey's branch that converts to SurfaceProducer)

Saw a similar (though slightly less, from ~20% spent in linked list traversal to ~13% in ArrayDeque traversal) to what was noted in this comment, so I'm going to land this

@gmackall gmackall marked this pull request as ready for review April 17, 2024 18:42
@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 17, 2024
@auto-submit auto-submit bot merged commit cc73c5c into flutter:main Apr 17, 2024
28 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 17, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Apr 17, 2024
…146940)

flutter/engine@376c86e...cc73c5c

2024-04-17 [email protected] Replace LinkedLists that are used as a queue in android FlutterRenderer with ArrayDeques (flutter/engine#51494)
2024-04-17 [email protected] [Impeller] Use booleans instead of counting backdrop reads. (flutter/engine#52181)
2024-04-17 [email protected] Update Skia's BUILD.gn (flutter/engine#52194)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
gilnobrega pushed a commit to gilnobrega/flutter that referenced this pull request Apr 22, 2024
…lutter#146940)

flutter/engine@376c86e...cc73c5c

2024-04-17 [email protected] Replace LinkedLists that are used as a queue in android FlutterRenderer with ArrayDeques (flutter/engine#51494)
2024-04-17 [email protected] [Impeller] Use booleans instead of counting backdrop reads. (flutter/engine#52181)
2024-04-17 [email protected] Update Skia's BUILD.gn (flutter/engine#52194)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
reidbaker pushed a commit to reidbaker/engine that referenced this pull request May 1, 2024
…er with ArrayDeques (flutter#51494)

Inspired by flutter#50767.

[As their documentation notes](https://docs.oracle.com/javase/8/docs/api/java/util/ArrayDeque.html), `ArrayDeque`s are generally faster than LinkedList when used as a queue.

Fixes flutter/flutter#143721

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
reidbaker pushed a commit to reidbaker/engine that referenced this pull request May 1, 2024
…er with ArrayDeques (flutter#51494)

Inspired by flutter#50767.

[As their documentation notes](https://docs.oracle.com/javase/8/docs/api/java/util/ArrayDeque.html), `ArrayDeque`s are generally faster than LinkedList when used as a queue.

Fixes flutter/flutter#143721

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
@reidbaker reidbaker mentioned this pull request May 1, 2024
8 tasks
auto-submit bot pushed a commit that referenced this pull request May 1, 2024
- **Replace LinkedLists that are used as a queue in android FlutterRenderer with ArrayDeques (#51494)**
- **Workaround HardwareRenderer breakage in Android 14 (#52370)**
Fixes flutter/flutter#147644

Includes #51494 to avoid merge conflicts and have a cleaner merge.
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 platform-android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Android] LinkedList iteration in ImageProducer is surprisingly slow
3 participants