Version: 2023.2
언어: 한국어
Dynamic heap allocator
Dual thread allocator

Bucket allocator

버킷 할당자는 작은 할당을 수행하는 빠른 무잠금 할당자입니다. 일반적으로 버킷 할당자는 힙 할당자로 이동하기 전에 작은 할당의 속도를 높이는 첫 번째 단계로 사용됩니다.

할당자는 할당을 위해 메모리 블록을 예약합니다. 각 블록은 16KB의 하위 섹션으로 나뉩니다. 이것은 설정할 수 없으며 사용자 인터페이스에 표시되지 않습니다. 각 하위 섹션은 할당으로 나뉩니다. 할당 크기는 세분화(granularity)라고 하는 설정된 고정 크기의 배수입니다.

Example configuration

The following example configuration demonstrates the process of reserving blocks for allocations:

Shared Bucket Allocator for the Windows, Mac and Linux Player
Shared Bucket Allocator for the Windows, Mac and Linux Player

이 설정에서 총 블록 크기(Bucket Allocator Block Size)는 4MB이고 할당 세분화(Bucket Allocator Granularity)는 16B입니다. 첫 번째 할당은 16B, 두 번째 할당은 32B(2*16), 다음 48B, 64B, 80B, 96B, 112B, 128B로 총 8개(Bucket Allocator BucketCount)의 버킷입니다.

각 하위 섹션에는 서로 다른 수의 버킷이 포함되어 있습니다. 하위 섹션의 버킷 수를 계산하려면 하위 섹션 크기(16KB)를 세분화로 나눕니다. 예를 들면 다음과 같습니다.

  • 할당 세분화가 64B인 경우 256개의 버킷이 하위 섹션에 들어갑니다.
  • 할당 세분화가 16B인 경우 1,024개의 버킷이 하위 섹션에 들어갑니다.

Development and release build comparison

Bucket allocators produce different usage reports for a development build and a release build because in a development build each allocation has an additional 40B header. The following diagram demonstrates the difference between development and release builds for 16B and 64B allocations:

개발 빌드와 릴리스 빌드의 비교
개발 빌드와 릴리스 빌드의 비교

The header is the reason the allocator reports being full after allocating only 2MB of its 4MB:

[ALLOC_BUCKET]
      Large Block size 4.0 MB
      Used Block count 1
      Peak Allocated bytes 2.0 MB
      Failed Allocations. Bucket layout:
        16B: 64 Subsections = 18724 buckets. Failed count: 3889
        32B: 17 Subsections = 3868 buckets. Failed count: 169583
        48B: 31 Subsections = 5771 buckets. Failed count: 39674
        64B: 28 Subsections = 4411 buckets. Failed count: 9981
        80B: 17 Subsections = 2321 buckets. Failed count: 14299
        96B: 6 Subsections = 722 buckets. Failed count: 9384
        112B: 44 Subsections = 4742 buckets. Failed count: 5909
        128B: 49 Subsections = 4778 buckets. Failed count: 8715

동일한 프로젝트의 릴리스 빌드에서는 할당자 블록 크기로 충분함을 보여줍니다.

[ALLOC_BUCKET]
      Large Block size 4.0 MB
      Used Block count 1
      Peak Allocated bytes 3.3 MB

버킷 할당자가 가득 차면 할당이 다른 할당자로 폴백됩니다. 사용량 보고서는 실패한 할당 수를 포함하여 사용 통계를 표시합니다. 보고서에서 실패 수가 선형적으로 증가하면 로드가 아닌 프레임을 계산할 때 할당이 실패했을 가능성이 있습니다. 폴백 할당은 씬 로드에 문제가 되지 않지만 프레임을 계산할 때 발생하면 성능에 영향을 미칠 수 있습니다.

To prevent these fallback allocations, increase the block size, and limit the new block size to match the frames’ peak usage, rather than the scene load peak usage. This prevents the block from becoming so large that it reserves a lot of memory which is then not available at runtime.

Tip: The Profiler allocators share an instance of a bucket allocator. You can customize this shared instance in the Profiler Shared Bucket Allocator.

Dynamic heap allocator
Dual thread allocator