Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Impeller] Started using a pool for HostBuffers. #44081

Merged
merged 9 commits into from
Aug 1, 2023

Conversation

gaaclarke
Copy link
Member

@gaaclarke gaaclarke commented Jul 27, 2023

This removes ~792 MB/s of allocation when scrolling around the Gallery ((358 MB - 226 MB) * 6).

before

Screenshot 2023-07-27 at 1 48 57 PM

after

Screenshot 2023-07-27 at 1 36 35 PM

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 Hixie said 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.

@gaaclarke gaaclarke marked this pull request as ready for review July 27, 2023 20:56
@gaaclarke
Copy link
Member Author

@chinmaygarde I'm guessing this isn't exactly how you want things laid out. Let me know where you want me to put stuff.

@gaaclarke
Copy link
Member Author

@jonahwilliams I made the pool threadsafe and I limited its size to a certain number of bytes (1MB), throwing away any buffer that happens to grow over 512K.

I also briefly looked into trying to convert the RenderPass create functions to unique_ptrs since in practice they don't actually have to be shared_ptr and it makes finding things like being passed to another thread harder to find. The change became difficult since our tests rely on those being shared_ptrs.

@gaaclarke
Copy link
Member Author

I also punted on using a lockless ring buffer for now.

Copy link
Member

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

I think this approach looks good to me. We have a similar pattern for recycling objects but it is vulkan specific, and I belive @chinmaygarde wants to hoist this up so we can use it in a non-backend specific manner.

So lets make sure this implementation can converge with the plans for texture recycling.

@chinmaygarde
Copy link
Member

I'm going to pick up the recycling work after subpasses. So not making any progress on it right now. Let's land this if it LGTY and handle the bigger recycling update later.

@gaaclarke gaaclarke merged commit 10a1f9c into flutter:main Aug 1, 2023
26 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 1, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Aug 1, 2023
…131696)

flutter/engine@1aadc75...10a1f9c

2023-08-01 30870216+gaaclarke@users.noreply.github.com [Impeller] Started using a pool for HostBuffers. (flutter/engine#44081)

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 jacksongardner@google.com,rmistry@google.com,zra@google.com 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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
vashworth pushed a commit to vashworth/flutter that referenced this pull request Aug 2, 2023
…lutter#131696)

flutter/engine@1aadc75...10a1f9c

2023-08-01 30870216+gaaclarke@users.noreply.github.com [Impeller] Started using a pool for HostBuffers. (flutter/engine#44081)

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 jacksongardner@google.com,rmistry@google.com,zra@google.com 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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
gaaclarke added a commit to gaaclarke/engine that referenced this pull request Aug 30, 2023
This removes ~792 MB/s of allocation when scrolling around the Gallery
((358 MB - 226 MB) * 6).

## before
<img width="1337" alt="Screenshot 2023-07-27 at 1 48 57 PM"
src="https://github.com/flutter/engine/assets/30870216/d320c2da-c333-40b7-9326-c9b69e5ff462">

## after
<img width="1391" alt="Screenshot 2023-07-27 at 1 36 35 PM"
src="https://github.com/flutter/engine/assets/30870216/e3314a03-8691-4766-9989-aef112703384">


## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [x] 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 Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat

---------

Co-authored-by: Jonah Williams <jonahwilliams@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants