This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Commit e3f817c
authored
[Impeller] moved to one staging buffer pool (#44172)
I measured the pool usage while using the wonderous app after having
consolidated the pools by printing capturing the pool usage after every
call of `vmaCreateBuffer`. The max number of allocations ever seen in
this pool were 1288704 B. Each of these pools are 32 MB. So this change
removes 64MB from the baseline memory usage of a Vulkan Flutter engine.
Worse case for a swapchain of 3 would be roughly 3 * 1.2 MB which is
well within the limits of the 32 MB buffer.
Using one pool also increases the likelihood that a buffer will have
been more recently used which leads to better memory performance.
This is safe to do since buffers will only be placed back into the pool
after they are disposed of.
## patch used for measuring
```diff
--- a/impeller/renderer/backend/vulkan/allocator_vk.cc
+++ b/impeller/renderer/backend/vulkan/allocator_vk.cc
@@ -474,6 +474,15 @@ std::shared_ptr<DeviceBuffer> AllocatorVK::OnCreateBuffer(
&buffer_allocation_info //
)};
+ VmaStatistics pool_stats;
+ ::vmaGetPoolStatistics(allocator_.get(), staging_buffer_pool_.get().pool,
+ &pool_stats);
+ static uint64_t s_max = 0;
+ if (pool_stats.allocationBytes > s_max) {
+ s_max = pool_stats.allocationBytes;
+ FML_LOG(ERROR) << "pool max: " << s_max;
+ }
+
if (result != vk::Result::eSuccess) {
VALIDATION_LOG << "Unable to allocate a device buffer: "
<< vk::to_string(result);
```
## 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].
- [ ] 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/Chat1 parent ae535c0 commit e3f817c
File tree
2 files changed
+7
-15
lines changed- impeller/renderer/backend/vulkan
2 files changed
+7
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
77 | | - | |
| 76 | + | |
78 | 77 | | |
79 | 78 | | |
80 | 79 | | |
| |||
161 | 160 | | |
162 | 161 | | |
163 | 162 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
| 163 | + | |
| 164 | + | |
168 | 165 | | |
169 | 166 | | |
170 | 167 | | |
| |||
460 | 457 | | |
461 | 458 | | |
462 | 459 | | |
463 | | - | |
| 460 | + | |
464 | 461 | | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
| 462 | + | |
469 | 463 | | |
470 | 464 | | |
471 | 465 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | 29 | | |
32 | 30 | | |
33 | | - | |
| 31 | + | |
34 | 32 | | |
35 | 33 | | |
36 | 34 | | |
37 | 35 | | |
38 | 36 | | |
39 | 37 | | |
40 | | - | |
| 38 | + | |
41 | 39 | | |
42 | 40 | | |
43 | 41 | | |
| |||
0 commit comments