Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

hash: use Go runtime's hash function #133

Merged
merged 1 commit into from Oct 12, 2018
Merged

hash: use Go runtime's hash function #133

merged 1 commit into from Oct 12, 2018

Conversation

alandonovan
Copy link
Contributor

@alandonovan alandonovan commented Oct 12, 2018

It uses AESENC instructions on amd64 and for strings of length >=12 starts to rapidly outperform the software implementation. It requires the linkname hack.

BenchmarkStringHash/hard-1-12         	300000000	         4.24 ns/op
BenchmarkStringHash/soft-1-12         	1000000000	         2.48 ns/op
BenchmarkStringHash/hard-2-12         	300000000	         4.88 ns/op
BenchmarkStringHash/soft-2-12         	500000000	         3.08 ns/op
BenchmarkStringHash/hard-4-12         	200000000	         6.19 ns/op
BenchmarkStringHash/soft-4-12         	300000000	         4.38 ns/op
BenchmarkStringHash/hard-8-12         	200000000	         7.58 ns/op
BenchmarkStringHash/soft-8-12         	300000000	         5.70 ns/op
BenchmarkStringHash/hard-16-12        	200000000	         8.49 ns/op
BenchmarkStringHash/soft-16-12        	100000000	        10.8 ns/op
BenchmarkStringHash/hard-32-12        	200000000	         8.68 ns/op
BenchmarkStringHash/soft-32-12        	50000000	        24.8 ns/op
BenchmarkStringHash/hard-64-12        	100000000	        10.5 ns/op
BenchmarkStringHash/soft-64-12        	30000000	        56.6 ns/op
BenchmarkStringHash/hard-128-12       	100000000	        15.3 ns/op
BenchmarkStringHash/soft-128-12       	10000000	       125 ns/op
BenchmarkStringHash/hard-256-12       	100000000	        17.7 ns/op
BenchmarkStringHash/soft-256-12       	 5000000	       267 ns/op
BenchmarkStringHash/hard-512-12       	50000000	        26.7 ns/op
BenchmarkStringHash/soft-512-12       	 3000000	       551 ns/op
BenchmarkStringHash/hard-1024-12      	30000000	        45.1 ns/op
BenchmarkStringHash/soft-1024-12      	 1000000	      1143 ns/op

It uses AESENC instructions on amd64 and for strings of length >=12 starts to rapidly outperform the software implementation. It requires the linkname hack.

BenchmarkStringHash/hard-1-12         	300000000	         4.24 ns/op
BenchmarkStringHash/soft-1-12         	1000000000	         2.48 ns/op
BenchmarkStringHash/hard-2-12         	300000000	         4.88 ns/op
BenchmarkStringHash/soft-2-12         	500000000	         3.08 ns/op
BenchmarkStringHash/hard-4-12         	200000000	         6.19 ns/op
BenchmarkStringHash/soft-4-12         	300000000	         4.38 ns/op
BenchmarkStringHash/hard-8-12         	200000000	         7.58 ns/op
BenchmarkStringHash/soft-8-12         	300000000	         5.70 ns/op
BenchmarkStringHash/hard-16-12        	200000000	         8.49 ns/op
BenchmarkStringHash/soft-16-12        	100000000	        10.8 ns/op
BenchmarkStringHash/hard-32-12        	200000000	         8.68 ns/op
BenchmarkStringHash/soft-32-12        	50000000	        24.8 ns/op
BenchmarkStringHash/hard-64-12        	100000000	        10.5 ns/op
BenchmarkStringHash/soft-64-12        	30000000	        56.6 ns/op
BenchmarkStringHash/hard-128-12       	100000000	        15.3 ns/op
BenchmarkStringHash/soft-128-12       	10000000	       125 ns/op
BenchmarkStringHash/hard-256-12       	100000000	        17.7 ns/op
BenchmarkStringHash/soft-256-12       	 5000000	       267 ns/op
BenchmarkStringHash/hard-512-12       	50000000	        26.7 ns/op
BenchmarkStringHash/soft-512-12       	 3000000	       551 ns/op
BenchmarkStringHash/hard-1024-12      	30000000	        45.1 ns/op
BenchmarkStringHash/soft-1024-12      	 1000000	      1143 ns/op
@alandonovan alandonovan merged commit f94b021 into master Oct 12, 2018
@alandonovan alandonovan deleted the hash branch October 12, 2018 19:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants