Related to 7632a0a313601b7269f0a3ea481a9e22a00028f9. A caller may use IImageAllocator to amortize allocations for the decoded image buffer when decoding multiple images. However, several other transient allocations are made which create memory traffic. By reducing these transient allocations, we reduce the number of garbage collections required for a performance boost.
We achieve this via a few approaches:
Use stackalloc to avoid allocating small arrays on the heap. As we are targeting netstandard 2.0 and not 2.1, we lack the ability to access the allocation safely via a Span. Instead, we must unsafely access the allocation via a pointer.
Use Array.Empty to avoid allocating new, empty arrays for mipmaps.
Use singletons for the IDecodeTarga classes, as they are stateless.
In INTColor.ToF16, use out parameters to avoid allocating a small array.
This provides the following benchmark improvements.
Related to 7632a0a313601b7269f0a3ea481a9e22a00028f9. A caller may use IImageAllocator to amortize allocations for the decoded image buffer when decoding multiple images. However, several other transient allocations are made which create memory traffic. By reducing these transient allocations, we reduce the number of garbage collections required for a performance boost.
We achieve this via a few approaches:
This provides the following benchmark improvements.
Before
After