Skip to content

Commit

Permalink
Update docs and benchmarks for v1.0.0. ~15% faster than v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cocowalla committed Apr 23, 2019
1 parent 83ea1ea commit 1ea5a1e
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CommonAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[assembly: ComVisible(false)]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("WyHash.UnitTests")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Benchmarks")]
31 changes: 22 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
wyhash-dotnet
=============
[![NuGet](https://img.shields.io/nuget/v/WyHash.svg)](https://www.nuget.org/packages/WyHash)

Zero-allocation C# implementation of [Wang Yi's](https://github.com/wangyi-fudan/wyhash) 64-bit **wyhash** hash algorithm and **wyrand** PRNG.

wyhash is an extremely fast, portable hashing algorithm, and passes all of the [SMHasher](https://github.com/rurban/smhasher) tests (which evaluates collision, dispersion and randomness qualities of hash functions).
Expand Down Expand Up @@ -52,7 +54,7 @@ Performance & Future Work
-------------------------
At present (April 2019), wyhash is the fastest algorithm in the [SMHasher](https://github.com/rurban/smhasher) benchmark.

On a dev laptop with 64GB RAM and an Intel Xeon CPU E3-1545M v5 2.90GHz CPU, this implementation can process data at a rate of around 3GB/s, which is *very* fast.
On a dev laptop with 64GB RAM and an Intel Xeon CPU E3-1545M v5 2.90GHz CPU, this implementation can process data at a rate of around 3.3GB/s, which is *very* fast.

Note that `PInvoke`ing into a native DLL built using the reference C code (see the `WyHash.Native` project) achieves around 10.8GB/s, so there is still work to do to bridge the performance gap.

Expand All @@ -71,15 +73,26 @@ Frequency=2836132 Hz, Resolution=352.5929 ns, Timer=TSC

Job=Core Runtime=Core

``` ini

BenchmarkDotNet=v0.11.5, OS=Windows 7 SP1 (6.1.7601.0)
Intel Xeon CPU E3-1545M v5 2.90GHz, 1 CPU, 8 logical and 4 physical cores
Frequency=2836132 Hz, Resolution=352.5929 ns, Timer=TSC
.NET Core SDK=2.2.105
[Host] : .NET Core 2.2.3 (CoreCLR 4.6.27414.05, CoreFX 4.6.27414.05), 64bit RyuJIT
Core : .NET Core 2.2.3 (CoreCLR 4.6.27414.05, CoreFX 4.6.27414.05), 64bit RyuJIT

Job=Core Runtime=Core

```
| Method | DataSize | Mean | Error | StdDev | Median | Min | Max | Ratio | RatioSD | Rank | Gen 0 | Gen 1 | Gen 2 | Allocated |
|----------------- |--------- |----------:|----------:|----------:|----------:|----------:|----------:|------:|--------:|-----:|------:|------:|------:|----------:|
| TestXxHash | 100 | 20.40 ns | 0.4396 ns | 0.3671 ns | 20.48 ns | 19.71 ns | 20.92 ns | 0.48 | 0.02 | 2 | - | - | - | - |
| TestXxHashNative | 100 | 24.53 ns | 0.5409 ns | 0.5313 ns | 24.43 ns | 23.95 ns | 25.71 ns | 0.58 | 0.02 | 3 | - | - | - | - |
| TestWyHashNative | 100 | 18.96 ns | 0.0906 ns | 0.0757 ns | 18.95 ns | 18.85 ns | 19.12 ns | 0.44 | 0.01 | 1 | - | - | - | - |
| *TestWyHash* | 100 | 40.53 ns | 0.8427 ns | 1.6829 ns | 39.59 ns | 39.13 ns | 44.56 ns | 1.00 | 0.00 | 4 | - | - | - | - |
| TestXxHash | 100 | 18.19 ns | 0.1241 ns | 0.1161 ns | 18.14 ns | 18.05 ns | 18.43 ns | 0.57 | 0.01 | 2 | - | - | - | - |
| TestXxHashNative | 100 | 21.85 ns | 0.1671 ns | 0.1563 ns | 21.90 ns | 21.63 ns | 22.08 ns | 0.69 | 0.01 | 3 | - | - | - | - |
| TestWyHashNative | 100 | 16.50 ns | 0.3931 ns | 1.1528 ns | 15.88 ns | 15.37 ns | 19.77 ns | 0.57 | 0.02 | 1 | - | - | - | - |
| *TestWyHash* | 100 | 31.84 ns | 0.2136 ns | 0.1998 ns | 31.85 ns | 31.47 ns | 32.18 ns | 1.00 | 0.00 | 4 | - | - | - | - |
| | | | | | | | | | | | | | | |
| TestXxHash | 1024 | 99.90 ns | 0.7521 ns | 0.6667 ns | 99.74 ns | 99.06 ns | 101.42 ns | 0.32 | 0.01 | 3 | - | - | - | - |
| TestXxHashNative | 1024 | 98.04 ns | 2.2641 ns | 3.2471 ns | 96.98 ns | 93.90 ns | 105.07 ns | 0.31 | 0.01 | 2 | - | - | - | - |
| TestWyHashNative | 1024 | 78.13 ns | 0.6726 ns | 0.5963 ns | 78.04 ns | 77.34 ns | 79.58 ns | 0.25 | 0.01 | 1 | - | - | - | - |
| *TestWyHash* | 1024 | 313.00 ns | 6.1691 ns | 8.6482 ns | 310.51 ns | 302.29 ns | 328.01 ns | 1.00 | 0.00 | 4 | - | - | - | - |
| TestXxHash | 1024 | 97.64 ns | 0.6791 ns | 0.6020 ns | 97.52 ns | 96.98 ns | 99.13 ns | 0.41 | 0.01 | 3 | - | - | - | - |
| TestXxHashNative | 1024 | 89.51 ns | 1.1083 ns | 1.0367 ns | 89.92 ns | 87.46 ns | 90.84 ns | 0.37 | 0.01 | 2 | - | - | - | - |
| TestWyHashNative | 1024 | 71.31 ns | 0.7103 ns | 0.6644 ns | 71.34 ns | 70.54 ns | 72.85 ns | 0.30 | 0.01 | 1 | - | - | - | - |
| *TestWyHash* | 1024 | 238.94 ns | 5.0078 ns | 5.1426 ns | 236.56 ns | 234.14 ns | 249.36 ns | 1.00 | 0.00 | 4 | - | - | - | - |
23 changes: 23 additions & 0 deletions benchmarks/1.0.1/WyHash.Benchmarks.Test-report-github.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
``` ini

BenchmarkDotNet=v0.11.5, OS=Windows 7 SP1 (6.1.7601.0)
Intel Xeon CPU E3-1545M v5 2.90GHz, 1 CPU, 8 logical and 4 physical cores
Frequency=2836132 Hz, Resolution=352.5929 ns, Timer=TSC
.NET Core SDK=2.2.105
[Host] : .NET Core 2.2.3 (CoreCLR 4.6.27414.05, CoreFX 4.6.27414.05), 64bit RyuJIT
Core : .NET Core 2.2.3 (CoreCLR 4.6.27414.05, CoreFX 4.6.27414.05), 64bit RyuJIT

Job=Core Runtime=Core

```
| Method | DataSize | Mean | Error | StdDev | Median | Min | Max | Ratio | RatioSD | Rank | Gen 0 | Gen 1 | Gen 2 | Allocated |
|----------------- |--------- |----------:|----------:|----------:|----------:|----------:|----------:|------:|--------:|-----:|------:|------:|------:|----------:|
| **TestXxHash** | **100** | **18.19 ns** | **0.1241 ns** | **0.1161 ns** | **18.14 ns** | **18.05 ns** | **18.43 ns** | **0.57** | **0.01** | **2** | **-** | **-** | **-** | **-** |
| TestXxHashNative | 100 | 21.85 ns | 0.1671 ns | 0.1563 ns | 21.90 ns | 21.63 ns | 22.08 ns | 0.69 | 0.01 | 3 | - | - | - | - |
| TestWyHashNative | 100 | 16.50 ns | 0.3931 ns | 1.1528 ns | 15.88 ns | 15.37 ns | 19.77 ns | 0.57 | 0.02 | 1 | - | - | - | - |
| TestWyHash | 100 | 31.84 ns | 0.2136 ns | 0.1998 ns | 31.85 ns | 31.47 ns | 32.18 ns | 1.00 | 0.00 | 4 | - | - | - | - |
| | | | | | | | | | | | | | | |
| **TestXxHash** | **1024** | **97.64 ns** | **0.6791 ns** | **0.6020 ns** | **97.52 ns** | **96.98 ns** | **99.13 ns** | **0.41** | **0.01** | **3** | **-** | **-** | **-** | **-** |
| TestXxHashNative | 1024 | 89.51 ns | 1.1083 ns | 1.0367 ns | 89.92 ns | 87.46 ns | 90.84 ns | 0.37 | 0.01 | 2 | - | - | - | - |
| TestWyHashNative | 1024 | 71.31 ns | 0.7103 ns | 0.6644 ns | 71.34 ns | 70.54 ns | 72.85 ns | 0.30 | 0.01 | 1 | - | - | - | - |
| TestWyHash | 1024 | 238.94 ns | 5.0078 ns | 5.1426 ns | 236.56 ns | 234.14 ns | 249.36 ns | 1.00 | 0.00 | 4 | - | - | - | - |
9 changes: 9 additions & 0 deletions benchmarks/1.0.1/WyHash.Benchmarks.Test-report.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Method,Job,AnalyzeLaunchVariance,EvaluateOverhead,MaxAbsoluteError,MaxRelativeError,MinInvokeCount,MinIterationTime,OutlierMode,Affinity,EnvironmentVariables,Jit,Platform,Runtime,AllowVeryLargeObjects,Concurrent,CpuGroups,Force,HeapAffinitizeMask,HeapCount,NoAffinitize,RetainVm,Server,PowerPlan,Arguments,BuildConfiguration,Clock,EngineFactory,NuGetReferences,Toolchain,IsMutator,InvocationCount,IterationCount,IterationTime,LaunchCount,MaxIterationCount,MaxWarmupIterationCount,MinIterationCount,MinWarmupIterationCount,RunStrategy,UnrollFactor,WarmupCount,DataSize,Mean,Error,StdDev,Median,Min,Max,Ratio,RatioSD,Rank,Gen 0,Gen 1,Gen 2,Allocated
TestXxHash,Core,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,X64,Core,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,1,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,100,18.19 ns,0.1241 ns,0.1161 ns,18.14 ns,18.05 ns,18.43 ns,0.57,0.01,2,-,-,-,-
TestXxHashNative,Core,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,X64,Core,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,1,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,100,21.85 ns,0.1671 ns,0.1563 ns,21.90 ns,21.63 ns,22.08 ns,0.69,0.01,3,-,-,-,-
TestWyHashNative,Core,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,X64,Core,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,1,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,100,16.50 ns,0.3931 ns,1.1528 ns,15.88 ns,15.37 ns,19.77 ns,0.57,0.02,1,-,-,-,-
TestWyHash,Core,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,X64,Core,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,1,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,100,31.84 ns,0.2136 ns,0.1998 ns,31.85 ns,31.47 ns,32.18 ns,1.00,0.00,4,-,-,-,-
TestXxHash,Core,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,X64,Core,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,1,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,1024,97.64 ns,0.6791 ns,0.6020 ns,97.52 ns,96.98 ns,99.13 ns,0.41,0.01,3,-,-,-,-
TestXxHashNative,Core,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,X64,Core,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,1,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,1024,89.51 ns,1.1083 ns,1.0367 ns,89.92 ns,87.46 ns,90.84 ns,0.37,0.01,2,-,-,-,-
TestWyHashNative,Core,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,X64,Core,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,1,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,1024,71.31 ns,0.7103 ns,0.6644 ns,71.34 ns,70.54 ns,72.85 ns,0.30,0.01,1,-,-,-,-
TestWyHash,Core,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,X64,Core,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,1,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,1024,238.94 ns,5.0078 ns,5.1426 ns,236.56 ns,234.14 ns,249.36 ns,1.00,0.00,4,-,-,-,-
39 changes: 39 additions & 0 deletions benchmarks/1.0.1/WyHash.Benchmarks.Test-report.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>WyHash.Benchmarks.Test-20190423-115039</title>

<style type="text/css">
table { border-collapse: collapse; display: block; width: 100%; overflow: auto; }
td, th { padding: 6px 13px; border: 1px solid #ddd; }
tr { background-color: #fff; border-top: 1px solid #ccc; }
tr:nth-child(even) { background: #f8f8f8; }
</style>
</head>
<body>
<pre><code>
BenchmarkDotNet=v0.11.5, OS=Windows 7 SP1 (6.1.7601.0)
Intel Xeon CPU E3-1545M v5 2.90GHz, 1 CPU, 8 logical and 4 physical cores
Frequency=2836132 Hz, Resolution=352.5929 ns, Timer=TSC
.NET Core SDK=2.2.105
[Host] : .NET Core 2.2.3 (CoreCLR 4.6.27414.05, CoreFX 4.6.27414.05), 64bit RyuJIT
Core : .NET Core 2.2.3 (CoreCLR 4.6.27414.05, CoreFX 4.6.27414.05), 64bit RyuJIT
</code></pre>
<pre><code>Job=Core Runtime=Core
</code></pre>

<table>
<thead><tr><th> Method</th><th>DataSize</th><th>Mean</th><th>Error</th><th>StdDev</th><th>Median</th><th>Min</th><th>Max</th><th>Ratio</th><th>RatioSD</th><th>Rank</th><th>Gen 0</th><th>Gen 1</th><th>Gen 2</th><th>Allocated</th>
</tr>
</thead><tbody><tr><td>TestXxHash</td><td>100</td><td>18.19 ns</td><td>0.1241 ns</td><td>0.1161 ns</td><td>18.14 ns</td><td>18.05 ns</td><td>18.43 ns</td><td>0.57</td><td>0.01</td><td>2</td><td>-</td><td>-</td><td>-</td><td>-</td>
</tr><tr><td>TestXxHashNative</td><td>100</td><td>21.85 ns</td><td>0.1671 ns</td><td>0.1563 ns</td><td>21.90 ns</td><td>21.63 ns</td><td>22.08 ns</td><td>0.69</td><td>0.01</td><td>3</td><td>-</td><td>-</td><td>-</td><td>-</td>
</tr><tr><td>TestWyHashNative</td><td>100</td><td>16.50 ns</td><td>0.3931 ns</td><td>1.1528 ns</td><td>15.88 ns</td><td>15.37 ns</td><td>19.77 ns</td><td>0.57</td><td>0.02</td><td>1</td><td>-</td><td>-</td><td>-</td><td>-</td>
</tr><tr><td>TestWyHash</td><td>100</td><td>31.84 ns</td><td>0.2136 ns</td><td>0.1998 ns</td><td>31.85 ns</td><td>31.47 ns</td><td>32.18 ns</td><td>1.00</td><td>0.00</td><td>4</td><td>-</td><td>-</td><td>-</td><td>-</td>
</tr><tr><td>TestXxHash</td><td>1024</td><td>97.64 ns</td><td>0.6791 ns</td><td>0.6020 ns</td><td>97.52 ns</td><td>96.98 ns</td><td>99.13 ns</td><td>0.41</td><td>0.01</td><td>3</td><td>-</td><td>-</td><td>-</td><td>-</td>
</tr><tr><td>TestXxHashNative</td><td>1024</td><td>89.51 ns</td><td>1.1083 ns</td><td>1.0367 ns</td><td>89.92 ns</td><td>87.46 ns</td><td>90.84 ns</td><td>0.37</td><td>0.01</td><td>2</td><td>-</td><td>-</td><td>-</td><td>-</td>
</tr><tr><td>TestWyHashNative</td><td>1024</td><td>71.31 ns</td><td>0.7103 ns</td><td>0.6644 ns</td><td>71.34 ns</td><td>70.54 ns</td><td>72.85 ns</td><td>0.30</td><td>0.01</td><td>1</td><td>-</td><td>-</td><td>-</td><td>-</td>
</tr><tr><td>TestWyHash</td><td>1024</td><td>238.94 ns</td><td>5.0078 ns</td><td>5.1426 ns</td><td>236.56 ns</td><td>234.14 ns</td><td>249.36 ns</td><td>1.00</td><td>0.00</td><td>4</td><td>-</td><td>-</td><td>-</td><td>-</td>
</tr></tbody></table>
</body>
</html>
8 changes: 4 additions & 4 deletions src/WyHash/WyHash.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<PropertyGroup>
<Description>Implementation of Wang Yi's wyhash 64-bit hash algorithm and wyrand PRNG. Reference implementation version 20190328</Description>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionPrefix>1.0.1</VersionPrefix>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<Authors>Colin Anderson</Authors>
<Copyright>Copyright © Colin Anderson 2019</Copyright>
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
<AssemblyName>WyHash</AssemblyName>
<RootNamespace>WyHash</RootNamespace>
<RepositoryUrl>http://github.com/cocowalla/wyhash-dotnet</RepositoryUrl>
<RepositoryUrl>https://github.com/cocowalla/wyhash-dotnet</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand All @@ -18,9 +18,9 @@
<PropertyGroup>
<IsPackable>true</IsPackable>
<PackageTags>wyhash;hash;cryptography;prng</PackageTags>
<PackageProjectUrl>http://github.com/cocowalla/wyhash-dotnet</PackageProjectUrl>
<PackageProjectUrl>https://github.com/cocowalla/wyhash-dotnet</PackageProjectUrl>
<PackageId>WyHash</PackageId>
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
<PackageLicenseUrl>https://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 1ea5a1e

Please sign in to comment.