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

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.

@gaaclarke gaaclarke requested a review from jonahwilliams July 28, 2023 17:14
Copy link
Contributor

@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
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 1, 2023
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 <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants