Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use an inline array for decompression scratch #86

Merged
merged 1 commit into from
Jan 8, 2024
Merged

Conversation

brantburnett
Copy link
Owner

Motivation

This array is small, fixed size, and always created. We can reduce heap allocations if it's inline within the class rather than a separate object on the heap.

Modifications

For .NET 8 only use a fixed array to store the block decompression scratch buffer.

Results

BenchmarkDotNet v0.13.10, Windows 11 (10.0.22621.2861/22H2/2022Update/SunValley2) 12th Gen Intel Core i7-1270P, 1 CPU, 16 logical and 12 physical cores .NET SDK 8.0.100
[Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
Job-SOJPFQ : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
Job-OKVMCF : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
Job-BRDMES : .NET 6.0.25 (6.0.2523.51912), X64 RyuJIT AVX2
Job-AJAIVB : .NET Framework 4.8.1 (4.8.9181.0), X64 RyuJIT VectorSize=256

Method Runtime PGO Mean Error StdDev Ratio RatioSD Rank Allocated Alloc Ratio
Array .NET 8.0 N 10.77 us 0.142 us 0.132 us 1.00 0.00 2 112 B 1.00
InlineArray .NET 8.0 N 10.53 us 0.168 us 0.157 us 0.98 0.02 1 80 B 0.71
Array .NET 8.0 Y 10.14 us 0.114 us 0.106 us 1.00 0.00 1 112 B 1.00
InlineArray .NET 8.0 Y 10.11 us 0.080 us 0.071 us 1.00 0.02 1 80 B 0.71

Motivation
----------
This array is small, fixed size, and always created. We can reduce heap
allocations if it's inline within the class rather than a separate
object on the heap.

Modifications
-------------
For .NET 8 only use a fixed array to store the block decompression
scratch buffer.

Results
-------
BenchmarkDotNet v0.13.10, Windows 11 (10.0.22621.2861/22H2/2022Update/SunValley2)
12th Gen Intel Core i7-1270P, 1 CPU, 16 logical and 12 physical cores
.NET SDK 8.0.100
  [Host]     : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
  Job-SOJPFQ : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
  Job-OKVMCF : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
  Job-BRDMES : .NET 6.0.25 (6.0.2523.51912), X64 RyuJIT AVX2
  Job-AJAIVB : .NET Framework 4.8.1 (4.8.9181.0), X64 RyuJIT VectorSize=256

| Method      | Runtime            | PGO | Mean     | Error    | StdDev   | Ratio | RatioSD | Rank | Allocated | Alloc Ratio |
|------------ |------------------- |---- |---------:|---------:|---------:|------:|--------:|-----:|----------:|------------:|
| Array       | .NET 8.0           | N   | 10.77 us | 0.142 us | 0.132 us |  1.00 |    0.00 |    2 |     112 B |        1.00 |
| InlineArray | .NET 8.0           | N   | 10.53 us | 0.168 us | 0.157 us |  0.98 |    0.02 |    1 |      80 B |        0.71 |
|             |                    |     |          |          |          |       |         |      |           |             |
| Array       | .NET 8.0           | Y   | 10.14 us | 0.114 us | 0.106 us |  1.00 |    0.00 |    1 |     112 B |        1.00 |
| InlineArray | .NET 8.0           | Y   | 10.11 us | 0.080 us | 0.071 us |  1.00 |    0.02 |    1 |      80 B |        0.71 |
@brantburnett brantburnett merged commit 4769e23 into main Jan 8, 2024
30 checks passed
@brantburnett brantburnett deleted the inlinearray branch January 8, 2024 13:35
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant