API v1 checking… · p50 — · 0 installs/hr
v0.1.0
Project
aras-p

UnitySmolRapidhash

New
12 0

Rapidhash V3 ported to C# with full Burst compilation support, providing a high-performance hashing solution for Unity. Offers significantly faster hashing than xxHash3 with minimal code overhead (under 100 lines), especially on ARM64 architectures. Includes flexible APIs supporting references, arrays, Spans, and NativeArrays for seamless integration into your project.

Unity Project

Built with Unity 2022.3.62f3 · download the source from GitHub

README

Rendered from GitHub

Rapidhash V3 port to C#/Unity/Burst

Port of rapidhash to C# (Unity+Burst). rapidhash is MIT license, and so is this port.

I made this as a package under Packages/org.nesnausk.smol-rapidhash in this repository, but really it is just the Packages/org.nesnausk.smol-rapidhash/Scripts/SmolRapidhash3.cs file that is barely over 100 lines long. You can just take it and use it (it needs Burst for the 128-bit multiply function, and enabling unsafe C# code in project settings).

API (similar to Unity.Collections package xxHash3 class:

  • static ulong Hash64<T>(ref T key) where T : unmanaged
  • static ulong Hash64<T>(T[] key) where T : unmanaged
  • static ulong Hash64<T>(Span<T> key) where T : unmanaged
  • static ulong Hash64<T>(NativeArray<T> key) where T : unmanaged
  • static ulong Hash64(void* key, long length)

Performance

Notes:

  • Burst approaches native (C) performance of rapidhash at larger input sizes. The calling benchmark program is just a C# (not Burst) script tested in the editor; might be cause of some overhead.
  • Rapidhash is always faster than xxhash (XXH3); the difference is more pronounced on arm64 (or at least on Apple CPUs).
  • Curiously enough, C#/Burst port of XXH3 (as provided by Unity.Collections package) is 30-40% slower than native (C) implementation. This slowdown is not there for rapidhash.

Ryzen 5950X / Windows / Visual Studio 2022 (17.14.23): rapidhash reaches about 38GB/s. Screenshot

Apple M4 Max / macOS / Xcode 16.1: rapidhash reaches about 67GB/s. Screenshot

Changelog 0 releases

No changelog entries yet. Run the admin Changelog & Version Scanner to pull from the repository's CHANGELOG.md.

Comments

No comments yet. Be the first!