src/common/PoolAlloc_unittest.cpp


Log

Author Commit Date CI Message
Kimmo Kinnunen 93b659f9 2025-07-04T12:35:29 Remove PoolAllocator push/pop feature PoolAllocator would manage a stack of memory pools upon client calling push() and pop(). This made the code unnecessarily complicated. The feature was only used with nesting of one, to mark the memory unused after a shader compile. Fix by removing the push/pop feature. Instantiate PoolAllocator in places the previous push() was and uninstantiating instead of previous pop(). This removes the feature where the PoolAllocator would hold on to the allocated memory in order to reuse it. This is seen as a progression: the allocator is held by the compiler, the compiler is held by the shader and each shader typically see only one compile. Thus the free pages were just leaking unused until the shader was destroyed. Instead, destructing the PoolAllocator instead of pop() will donate the memory back to platform/OS, where it is likely more useful. To preserve existing Vulkan behavior, add PoolAllocator::reset() which would mark the memory unused but leave them reserved for the PoolAllocator. Removes UB where PageHeader::nextPage would be accessed after ~PageHeader. Bug: angleproject:429513168 Change-Id: I21e58b46e0887380db3a2cab5ce22f0042cfae9e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6701153 Reviewed-by: Geoff Lang <geofflang@chromium.org> Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Kimmo Kinnunen e1d5d8c0 2023-01-26T16:06:14 Include stdint.h instead of cstdint in platform.h The project seems to expect use of stdint.h, since almost none of uint*_t, int*_t use are prefixed with std:: namespace. It is reasonable to expect a contract that platform.h includes some specific files from the standard library when it establishes the "platform for ANGLE". It appears that the contract kind of already includes stdint.h types or defines. Replace <cstdint> in platform.h with <stdint.h>. The file platform.h is included from many files, so those files do not need to include the stdint.h redundantly. Remove #include <stdint.h> from Constants.h, as that file already includes platform.h and <stdint.h> is part of the "platform". Bug: angleproject:7977 Change-Id: I04563eb3680bcd7470775e3a60b9f466a00b8b63 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4194174 Commit-Queue: Kenneth Russell <kbr@chromium.org> Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Jamie Madill 100ebfd7 2021-10-13T12:07:21 Revert "Re-enable PoolAllocatorAlignmentTest.Alignment" This reverts commit 7eada73ac4964df5ffd539efb7a0569a97e4fd3d. Reason for revert: Breaking Lollipop tester likely b/c of 32-bit issues. Bug: chromium:1259544 Original change's description: > Re-enable PoolAllocatorAlignmentTest.Alignment > > The PoolAllocatorAlignmentTest.Alignment/64 variant of the test fails on > windows/debug, so this change re-enables this test everywhere except for > that variant (and speculatively /128) on windows. > > Bug: angleproject:6536 > Change-Id: Ibc4fcbe04e7579f3ad7eb68f4f460078ee27ac88 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3212329 > Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Bug: angleproject:6536 Change-Id: I74ebf1c78c8b15c14c9d1496948adafd13e0d2ba No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3220971 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 7eada73a 2021-10-07T11:09:50 Re-enable PoolAllocatorAlignmentTest.Alignment The PoolAllocatorAlignmentTest.Alignment/64 variant of the test fails on windows/debug, so this change re-enables this test everywhere except for that variant (and speculatively /128) on windows. Bug: angleproject:6536 Change-Id: Ibc4fcbe04e7579f3ad7eb68f4f460078ee27ac88 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3212329 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Yuly Novikov d14d0c39 2021-10-06T20:41:12 Redisable PoolAllocatorAlignmentTest.Alignment in Debug Was enabled by crrev.com/c/3206255, but fails. Bug: angleproject:3167, chromium:1257395 Change-Id: Ibe34128c4479c7c2706270e04ef39b5ec29eb1a9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3210013 Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
Shahbaz Youssefi 71984bff 2021-10-05T14:59:26 Reduce memory waste in PoolAllocator due to alignments Prior to this change, the PoolAllocator wasted memory in alignments. This was due to the fact that alignment was made to the wrong values, and they were fixed with more alignments and conservative extra space allocations. This change makes sure that alignment is applied once, and such that the actual pointer that needs to be aligned is aligned, not the header that might come before it, and that allocation size is calculated precisely. This improves memory allocation by reducing waste, but only affects the use of the pool in the translator, as Vulkan secondary command buffers (the other user) use an alignment of 1 and take a different path. Running TracePerfTest.Run/vulkan_manhattan_10 on Linux, the total size of allocations made by this class for the translator goes down from 466944 bytes to 376832 bytes for a ~20% improvement. Bug: angleproject:3167 Change-Id: Ib4e6fd23ac32c8fb21810b20cd383758b8bff47f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3206255 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Tobin Ehlis 5546fb4f 2019-01-17T12:25:54 Vulkan:Adding custom pool allocator Migrated pool allocator used by compiler to common. Planning to use this for ANGLE custom command buffers so this some refactoring in preparation for that work. Added a unit test to check PoolAllocator functionality. Bug: angleproject:2951 Reviewed-on: https://chromium-review.googlesource.com/c/1476953 Reviewed-by: Jamie Madill <jmadill@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Tobin Ehlis <tobine@google.com> Change-Id: I0b4f3d55ea1799e35c9799c221f7129233f30b24 Reviewed-on: https://chromium-review.googlesource.com/c/1492972
Yuly Novikov 0546b538 2019-02-25T22:47:17 Revert "Vulkan:Adding custom pool allocator" This reverts commit 941717496141b96f1d5817f31c2bb4a4e19847b9. Reason for revert: crashes on Debug bots Original change's description: > Vulkan:Adding custom pool allocator > > Migrated pool allocator used by compiler to common. > > Planning to use this for ANGLE custom command buffers so this some > refactoring in preparation for that work. > > Added a unit test to check PoolAllocator functionality. > > Bug: angleproject:2951 > Change-Id: I29618cfdb065b8a5fefd40719a35d27b1f6e99ef > Reviewed-on: https://chromium-review.googlesource.com/c/1476953 > Reviewed-by: Jamie Madill <jmadill@google.com> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Commit-Queue: Tobin Ehlis <tobine@google.com> TBR=ynovikov@chromium.org,jmadill@google.com,tobine@google.com,syoussefi@chromium.org Change-Id: Id8c522bd1d94154e871211d975e801a55cc9c257 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: angleproject:2951, angleproject:3169 Reviewed-on: https://chromium-review.googlesource.com/c/1487977 Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
Tobin Ehlis 94171749 2019-01-17T12:25:54 Vulkan:Adding custom pool allocator Migrated pool allocator used by compiler to common. Planning to use this for ANGLE custom command buffers so this some refactoring in preparation for that work. Added a unit test to check PoolAllocator functionality. Bug: angleproject:2951 Change-Id: I29618cfdb065b8a5fefd40719a35d27b1f6e99ef Reviewed-on: https://chromium-review.googlesource.com/c/1476953 Reviewed-by: Jamie Madill <jmadill@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Tobin Ehlis <tobine@google.com>