Giter Club home page Giter Club logo

triehash's Introduction

Order-preserving minimal perfect hash function generator

Build order-preserving minimal perfect hash functions.

codecov Build Status

Performance

Performance was evaluated against other hash functions. As an input set, the fields of Debian Packages and Sources files was used, and each hash function was run 1,000,000 times for each word. The byte count of the words were then summed up and divided by the total number of nanoseconds each function ran, so all speeds below are given in bytes per nanosecond, AKA gigabyte per second.

arch/function jak-x230 (amd64) backup (amd64) asachi.d.o (arm64) asachi.d.o (armel) asachi.d.o (armhf) plummer.d.o (ppc64el) eller.d.o (mipsel)
Trie 2.4 1.9 1.2 0.9 0.8 2.0 0.2
Trie (*) 2.2 1.7 0.8 0.7 0.7 1.8 0.2
re2c 1.7 1.3 0.9 0.9 0.7 1.6 0.2
re2c (*) 1.2 0.9 0.6 0.6 0.5 1.1 0.1
gperf (*) 0.7 0.5 0.2 0.2 0.2 0.5 0.1
gperf 1.3 0.9 0.3 0.3 0.2 0.4 0.1
djb (*) 0.7 0.5 0.3 0.3 0.3 0.5 0.1
djb (**) 1.0 0.7 0.4 0.5 0.5 0.6 0.2
djb 0.9 0.7 0.5 0.5 0.5 0.7 0.2
apt (*) 1.2 0.9 0.7 0.7 0.7 1.1 0.2
apt (**) 2.3 1.7 0.7 0.9 0.8 1.9 0.2

And transposed:

function/arch Trie Trie (*) re2c re2c (*) gperf (*) gperf djb (*) djb (**) djb apt (*) apt (**)
jak-x230 (amd64) 2.4 2.2 1.7 1.2 0.7 1.3 0.7 1.0 0.9 1.2 2.3
backup (amd64) 1.9 1.7 1.3 0.9 0.5 0.9 0.5 0.7 0.7 0.9 1.7
asachi.d.o (arm64) 1.2 0.8 0.9 0.6 0.2 0.3 0.3 0.4 0.5 0.7 0.7
asachi.d.o (armel) 0.9 0.7 0.9 0.6 0.2 0.3 0.3 0.5 0.5 0.7 0.9
asachi.d.o (armhf) 0.8 0.7 0.7 0.5 0.2 0.2 0.3 0.5 0.5 0.7 0.8
plummer.d.o (ppc64el) 2.0 1.8 1.6 1.1 0.5 0.4 0.5 0.6 0.7 1.1 1.9
eller.d.o (mipsel) 0.2 0.2 0.2 0.1 0.1 0.1 0.1 0.2 0.2 0.2 0.2

Legend:

  • The () variants are case-insensitive, (**) are more optimised versions of the () versions.
  • DJB (*) is a DJB Hash with naive lowercase conversion, DJB (**) just ORs one bit into each value to get alphabetical characters to be lowercase
  • APT (*) is the AlphaHash function from APT which hashes the last 8 bytes in a word in a case-insensitive manner. APT (**) is the same function unrolled.
  • All hosts except the x230 are Debian porterboxes. The x230 has a Core i5-3320M, barriere has an Opteron 23xx.

Notes:

triehash's People

Contributors

donkult avatar guillemj avatar julian-klode avatar jwilk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

triehash's Issues

Reproducible benchmark code?

Is the code used to produce the numbers in the readme available somewhere? Based on the methodology described, it seems likely that triehash is benefiting significantly from (unrealistically favourable) branch prediction:

... each hash function was run 1,000,000 times for each word

Fails to compile/run with `syntax error at ./triehash.pl line 221, near "package Trie {`

$ git log --oneline --no-decorate -1
e0bd5e0 Merge pull request #2 from jwilk-forks/spelling
$ ./triehash.pl
Invalid version format (non-numeric data) at ./triehash.pl line 219, near "package Trie "
syntax error at ./triehash.pl line 221, near "package Trie {

    "
Execution of ./triehash.pl aborted due to compilation errors.
$ perl --version

This is perl 5, version 12, subversion 1 (v5.12.1) built for x86_64-linux-thread-multi

Copyright 1987-2010, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

$ git log --oneline --no-decorate -1
e0bd5e0 Merge pull request #2 from jwilk-forks/spelling

$ prun perl perl --version

This is perl 5, version 34, subversion 0 (v5.34.0) built for x86_64-linux-thread-multi

Copyright 1987-2021, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.