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 CRC32 hash when available during compression #66

Merged
merged 2 commits into from
Feb 24, 2023
Merged

Conversation

brantburnett
Copy link
Owner

Motivation

The reference Snappy implementation has switched to this approach to get a performance gain.

Modifications

When CRC32C intrinsics are available on x86 or ARM use them to index into the hash table. Also rework the hash operations to use a reference to make it faster to write back to the same location after each step.

Results

BenchmarkDotNet=v0.13.4, OS=Windows 11 (10.0.22000.1455/21H2) Intel Core i7-10850H CPU 2.70GHz, 1 CPU, 12 logical and 6 physical cores .NET SDK=7.0.200
[Host] : .NET 7.0.3 (7.0.323.6910), X64 RyuJIT AVX2
Job-NOAZVY : .NET 7.0.3 (7.0.323.6910), X64 RyuJIT AVX2
Job-WNHWWN : .NET 6.0.14 (6.0.1423.7309), X64 RyuJIT AVX2
Job-MXBHYC : .NET 7.0.3 (7.0.323.6910), X64 RyuJIT AVX2
Job-AZKGJL : .NET Framework 4.8 (4.8.4614.0), X64 RyuJIT VectorSize=256

Method Runtime PGO Mean Error StdDev Median Ratio RatioSD Rank
Legacy .NET 7.0 Y 112.9 us 1.93 us 1.81 us 113.1 us 1.00 0.00 2
New .NET 7.0 Y 109.6 us 0.20 us 0.16 us 109.6 us 0.97 0.02 1
Legacy .NET 6.0 N 121.8 us 2.42 us 2.89 us 120.7 us 1.00 0.00 2
New .NET 6.0 N 117.2 us 2.30 us 2.56 us 118.2 us 0.96 0.04 1
Legacy .NET 7.0 N 118.3 us 2.36 us 2.62 us 116.4 us 1.00 0.00 1
New .NET 7.0 N 116.5 us 0.18 us 0.15 us 116.5 us 0.99 0.02 1
Legacy .NET Framework 4.8 N 210.6 us 4.15 us 5.40 us 210.0 us 1.00 0.00 1
New .NET Framework 4.8 N 211.5 us 3.94 us 4.05 us 213.2 us 1.00 0.03 1

Motivation
----------
The reference Snappy implementation has switched to this approach to get
a performance gain.

Modifications
-------------
When CRC32C intrinsics are available on x86 or ARM use them to index
into the hash table. Also rework the hash operations to use a reference
to make it faster to write back to the same location after each step.

Results
-------
BenchmarkDotNet=v0.13.4, OS=Windows 11 (10.0.22000.1455/21H2)
Intel Core i7-10850H CPU 2.70GHz, 1 CPU, 12 logical and 6 physical cores
.NET SDK=7.0.200
  [Host]     : .NET 7.0.3 (7.0.323.6910), X64 RyuJIT AVX2
  Job-NOAZVY : .NET 7.0.3 (7.0.323.6910), X64 RyuJIT AVX2
  Job-WNHWWN : .NET 6.0.14 (6.0.1423.7309), X64 RyuJIT AVX2
  Job-MXBHYC : .NET 7.0.3 (7.0.323.6910), X64 RyuJIT AVX2
  Job-AZKGJL : .NET Framework 4.8 (4.8.4614.0), X64 RyuJIT VectorSize=256

| Method |            Runtime | PGO |     Mean |   Error |  StdDev |   Median | Ratio | RatioSD | Rank |
|------- |------------------- |---- |---------:|--------:|--------:|---------:|------:|--------:|-----:|
| Legacy |           .NET 7.0 |   Y | 112.9 us | 1.93 us | 1.81 us | 113.1 us |  1.00 |    0.00 |    2 |
|    New |           .NET 7.0 |   Y | 109.6 us | 0.20 us | 0.16 us | 109.6 us |  0.97 |    0.02 |    1 |
|        |                    |     |          |         |         |          |       |         |      |
| Legacy |           .NET 6.0 |   N | 121.8 us | 2.42 us | 2.89 us | 120.7 us |  1.00 |    0.00 |    2 |
|    New |           .NET 6.0 |   N | 117.2 us | 2.30 us | 2.56 us | 118.2 us |  0.96 |    0.04 |    1 |
|        |                    |     |          |         |         |          |       |         |      |
| Legacy |           .NET 7.0 |   N | 118.3 us | 2.36 us | 2.62 us | 116.4 us |  1.00 |    0.00 |    1 |
|    New |           .NET 7.0 |   N | 116.5 us | 0.18 us | 0.15 us | 116.5 us |  0.99 |    0.02 |    1 |
|        |                    |     |          |         |         |          |       |         |      |
| Legacy | .NET Framework 4.8 |   N | 210.6 us | 4.15 us | 5.40 us | 210.0 us |  1.00 |    0.00 |    1 |
|    New | .NET Framework 4.8 |   N | 211.5 us | 3.94 us | 4.05 us | 213.2 us |  1.00 |    0.03 |    1 |
@brantburnett brantburnett merged commit 862caf6 into main Feb 24, 2023
@brantburnett brantburnett deleted the crc32-hash branch February 24, 2023 00:45
# 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