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

Improve .NET 8 stream decompression perf #84

Merged
merged 1 commit into from
Jan 6, 2024
Merged

Conversation

brantburnett
Copy link
Owner

Motivation

.NET 8 has shown a significant regression when decompressing streams, though not blocks.

Modifications

Drop some overly aggressive inlining on cold paths, which may provide better enregistration. Also, for .NET 8 use an inline array to avoid allocating the scratch buffer on the heap.

Results

The regression has been effectively eliminated.

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-EHUKKX : .NET Framework 4.8.1 (4.8.9181.0), X64 RyuJIT VectorSize=256
Job-SIHOZS : .NET Framework 4.8.1 (4.8.9181.0), X64 RyuJIT VectorSize=256
Job-VAGBBP : .NET 6.0.25 (6.0.2523.51912), X64 RyuJIT AVX2
Job-ZACCID : .NET 6.0.25 (6.0.2523.51912), X64 RyuJIT AVX2
Job-ACXPKE : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
Job-JFCQYT : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
Job-CWWXAC : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
Job-IDGNPX : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2

Method Runtime BuildConfiguration PGO Mean Error StdDev Ratio Rank
Decompress .NET Framework 4.8 Previous N 342.7 us 1.73 us 1.45 us 1.00 2
Decompress .NET Framework 4.8 Default N 334.7 us 0.85 us 0.80 us 0.98 1
Decompress .NET 6.0 Previous N 168.5 us 1.43 us 1.34 us 1.00 2
Decompress .NET 6.0 Default N 164.8 us 0.78 us 0.73 us 0.98 1
Decompress .NET 8.0 Previous N 199.9 us 1.64 us 1.53 us 1.00 2
Decompress .NET 8.0 Default N 160.7 us 1.42 us 1.33 us 0.80 1
Decompress .NET 8.0 Previous Y 191.3 us 1.05 us 0.98 us 1.00 2
Decompress .NET 8.0 Default Y 160.9 us 1.50 us 1.40 us 0.84 1

Note: Benchmarks include other improvements since 1.1.3

Motivation
----------
.NET 8 has shown a significant regression when decompressing streams,
though not blocks.

Modifications
-------------
Drop some overly aggressive inlining on cold paths, which may provide
better enregistration. Also, for .NET 8 use an inline array to avoid
allocating the scratch buffer on the heap.

Results
-------
The regression has been effectively eliminated.

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-EHUKKX : .NET Framework 4.8.1 (4.8.9181.0), X64 RyuJIT VectorSize=256
  Job-SIHOZS : .NET Framework 4.8.1 (4.8.9181.0), X64 RyuJIT VectorSize=256
  Job-VAGBBP : .NET 6.0.25 (6.0.2523.51912), X64 RyuJIT AVX2
  Job-ZACCID : .NET 6.0.25 (6.0.2523.51912), X64 RyuJIT AVX2
  Job-ACXPKE : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
  Job-JFCQYT : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
  Job-CWWXAC : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
  Job-IDGNPX : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2

| Method     | Runtime            | BuildConfiguration | PGO | Mean     | Error   | StdDev  | Ratio | Rank |
|----------- |------------------- |------------------- |---- |---------:|--------:|--------:|------:|-----:|
| Decompress | .NET Framework 4.8 | Previous           | N   | 342.7 us | 1.73 us | 1.45 us |  1.00 |    2 |
| Decompress | .NET Framework 4.8 | Default            | N   | 334.7 us | 0.85 us | 0.80 us |  0.98 |    1 |
|            |                    |                    |     |          |         |         |       |      |
| Decompress | .NET 6.0           | Previous           | N   | 168.5 us | 1.43 us | 1.34 us |  1.00 |    2 |
| Decompress | .NET 6.0           | Default            | N   | 164.8 us | 0.78 us | 0.73 us |  0.98 |    1 |
|            |                    |                    |     |          |         |         |       |      |
| Decompress | .NET 8.0           | Previous           | N   | 199.9 us | 1.64 us | 1.53 us |  1.00 |    2 |
| Decompress | .NET 8.0           | Default            | N   | 160.7 us | 1.42 us | 1.33 us |  0.80 |    1 |
|            |                    |                    |     |          |         |         |       |      |
| Decompress | .NET 8.0           | Previous           | Y   | 191.3 us | 1.05 us | 0.98 us |  1.00 |    2 |
| Decompress | .NET 8.0           | Default            | Y   | 160.9 us | 1.50 us | 1.40 us |  0.84 |    1 |

Note: Benchmarks include other improvements since 1.1.3
@brantburnett brantburnett merged commit 77834c8 into main Jan 6, 2024
30 checks passed
@brantburnett brantburnett deleted the stream-decompress branch January 6, 2024 18:24
# 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