Skip to content

Commit f97a238

Browse files
committed
Improve perfomance for XXH128 & XXH3
1 parent 91b72f2 commit f97a238

File tree

11 files changed

+552
-3591
lines changed

11 files changed

+552
-3591
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 2022-07-17
2+
- Improve perfomance for XXH32 & XXH64
3+
- Improve perfomance for XXH128 & XXH3
14
# 2022-06-13
25
- Added xxHash3
36
# 2022-06-05

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ Runtime=.NET 6.0
5555
| Hash32 | x64 | C | 140.2 ns | 129.6 us | 150.3 ms | 6.65 GB/s |
5656
| Hash64 | x64 | C# | 73.9 ns | 64.6 us | 81.4 ms | 12.28 GB/s |
5757
| Hash64 | x64 | C | 75.5 ns | 65.2 us | 84.5 ms | 11.83 GB/s |
58-
| Hash128 (SSE2/AVX2)| x64 | C# | 151.6 ns | 64.5 us | 80.5 ms | 12.04 GB/s |
59-
| Hash128 (SSE2/AVX2)| x64 | C | 84.4 ns | 38.3 us | 57.4 ms | 17.42 GB/s |
60-
| Hash3 (SSE2/AVX2)| x64 | C# | 77.6 ns | 62.1 us | 78.5 ms | 12.08 GB/s |
61-
| Hash3 (SSE2/AVX2)| x64 | C | 73.7 ns | 42.2 us | 59.8 ms | 16.72 GB/s |
58+
| Hash128 (SSE2/AVX2)| x64 | C# | 84.95 ns | 56.9 us | 73.2 ms | 13.66 GB/s |
59+
| Hash128 (SSE2/AVX2)| x64 | C | 84.35 ns | 38.1 us | 57.2 ms | 17.48 GB/s |
60+
| Hash3 (SSE2/AVX2)| x64 | C# | 75.8 ns | 56.6 us | 74.6 ms | 13.40 GB/s |
61+
| Hash3 (SSE2/AVX2)| x64 | C | 74.1 ns | 42.1 us | 59.5 ms | 16.80 GB/s |
6262

6363

6464
## Api

nuget.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>net6.0</TargetFramework>
55
<PackageId>Standart.Hash.xxHash</PackageId>
6-
<VersionPrefix>4.0.3</VersionPrefix>
6+
<VersionPrefix>4.0.4</VersionPrefix>
77
<AssemblyName>Standart.Hash.xxHash</AssemblyName>
88
<AssemblyTitle>Standart.Hash.xxHash</AssemblyTitle>
99
<Authors>Oleksandr Melnyk</Authors>

src/Standart.Hash.xxHash/__inline__xxHash128.cs

Lines changed: 0 additions & 1834 deletions
This file was deleted.

src/Standart.Hash.xxHash/__inline__xxHash3.cs

Lines changed: 0 additions & 1419 deletions
This file was deleted.

src/Standart.Hash.xxHash/xxHash128.XXH.cs

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,40 @@
11
// ReSharper disable InconsistentNaming
22

33
using System.Runtime.CompilerServices;
4+
using System.Runtime.Intrinsics;
45
using System.Runtime.Intrinsics.X86;
56

67
namespace Standart.Hash.xxHash
78
{
89
public static partial class xxHash128
910
{
10-
private const ulong XXH_PRIME64_1 = 11400714785074694791UL;
11-
private const ulong XXH_PRIME64_2 = 14029467366897019727UL;
12-
private const ulong XXH_PRIME64_3 = 1609587929392839161UL;
13-
private const ulong XXH_PRIME64_4 = 9650029242287828579UL;
14-
private const ulong XXH_PRIME64_5 = 2870177450012600261UL;
15-
16-
private const uint XXH_PRIME32_1 = 2654435761U;
17-
private const uint XXH_PRIME32_2 = 2246822519U;
18-
private const uint XXH_PRIME32_3 = 3266489917U;
19-
private const uint XXH_PRIME32_4 = 668265263U;
20-
private const uint XXH_PRIME32_5 = 374761393U;
11+
private static readonly ulong XXH_PRIME64_1 = 11400714785074694791UL;
12+
private static readonly ulong XXH_PRIME64_2 = 14029467366897019727UL;
13+
private static readonly ulong XXH_PRIME64_3 = 1609587929392839161UL;
14+
private static readonly ulong XXH_PRIME64_4 = 9650029242287828579UL;
15+
private static readonly ulong XXH_PRIME64_5 = 2870177450012600261UL;
16+
17+
private static readonly uint XXH_PRIME32_1 = 2654435761U;
18+
private static readonly uint XXH_PRIME32_2 = 2246822519U;
19+
private static readonly uint XXH_PRIME32_3 = 3266489917U;
20+
private static readonly uint XXH_PRIME32_4 = 668265263U;
21+
private static readonly uint XXH_PRIME32_5 = 374761393U;
22+
23+
private static readonly int XXH_STRIPE_LEN = 64;
24+
private static readonly int XXH_ACC_NB = 8;
25+
private static readonly int XXH_SECRET_CONSUME_RATE = 8;
26+
private static readonly int XXH_SECRET_MERGEACCS_START = 11;
27+
private static readonly int XXH_SECRET_DEFAULT_SIZE = 192;
28+
private static readonly int XXH_SECRET_LASTACC_START = 7;
29+
30+
private static readonly byte MM_SHUFFLE_0_3_0_1 = 0b0011_0001;
31+
private static readonly byte MM_SHUFFLE_1_0_3_2 = 0b0100_1110;
32+
33+
[FixedAddressValueType]
34+
private static readonly Vector256<uint> M256i_XXH_PRIME32_1 = Vector256.Create(XXH_PRIME32_1);
35+
[FixedAddressValueType]
36+
private static readonly Vector128<uint> M128i_XXH_PRIME32_1 = Vector128.Create(XXH_PRIME32_1);
2137

22-
private const int XXH_STRIPE_LEN = 64;
23-
private const int XXH_ACC_NB = XXH_STRIPE_LEN / 8;
24-
private const int XXH_SECRET_CONSUME_RATE = 8;
25-
private const int XXH_SECRET_MERGEACCS_START = 11;
26-
private const int XXH_SECRET_DEFAULT_SIZE = 192;
27-
private const int XXH_SECRET_LASTACC_START = 7;
2838

2939
[MethodImpl(MethodImplOptions.AggressiveInlining)]
3040
private static uint XXH_rotl32(uint x, int r)

0 commit comments

Comments
 (0)