Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some bounds checking can be eliminated for extra speed #4

Closed
Marreck opened this issue Aug 29, 2018 · 0 comments
Closed

Some bounds checking can be eliminated for extra speed #4

Marreck opened this issue Aug 29, 2018 · 0 comments

Comments

@Marreck
Copy link
Contributor

Marreck commented Aug 29, 2018

I have been looking at the performance of this package, specifically at bounds check elimination that was introduced since Go 1.7.

Using go build -gcflags="-d=ssa/check_bce/debug=1" it seems there is a lot of bounds checking going on. Eliminating might in some cases increase performance so I took a quick look if there is some low hanging fruit to be found. There is 1 minor change that can be implemented that impacts performance quit a lot in the 10 Percent hitrate benchmark on my machine:

Before:

goarch: amd64
pkg: github.com/Marreck/intintmap
BenchmarkIntIntMapFill-4                   	      10	 158195310 ns/op
BenchmarkStdMapFill-4                      	       5	 281591720 ns/op
BenchmarkIntIntMapGet10PercentHitRate-4    	   20000	     70048 ns/op
BenchmarkStdMapGet10PercentHitRate-4       	   20000	     65797 ns/op
BenchmarkIntIntMapGet100PercentHitRate-4   	     500	   3021940 ns/op
BenchmarkStdMapGet100PercentHitRate-4      	     100	  10399684 ns/op
PASS

After:

goarch: amd64
pkg: github.com/Marreck/intintmap
BenchmarkIntIntMapFill-4                   	      10	 159295270 ns/op
BenchmarkStdMapFill-4                      	       5	 282393180 ns/op
BenchmarkIntIntMapGet10PercentHitRate-4    	   20000	     58797 ns/op
BenchmarkStdMapGet10PercentHitRate-4       	   20000	     67847 ns/op
BenchmarkIntIntMapGet100PercentHitRate-4   	     500	   2955890 ns/op
BenchmarkStdMapGet100PercentHitRate-4      	     100	  10299620 ns/op
PASS
@Marreck Marreck closed this as completed Oct 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant