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

runtime: improve interface equality check performance #6105

Closed
ugorji opened this issue Aug 11, 2013 · 3 comments
Closed

runtime: improve interface equality check performance #6105

ugorji opened this issue Aug 11, 2013 · 3 comments
Milestone

Comments

@ugorji
Copy link
Contributor

ugorji commented Aug 11, 2013

Interface equality check is expensive compared to integer comparison check.

In the benchmark, I compare two integers. I then wrap them in interface{} and compare
them.

As interface{}, the comparison check takes over 20X the time taken by just plain
comparison check.

See http://play.golang.org/p/1evwkTYYlB

Results:
BenchmarkIntfEqual  100000000            14.5 ns/op
BenchmarkReflectTypeEqual   100000000    14.4 ns/op
BenchmarkPtrEqual   2000000000           1.06 ns/op
BenchmarkIntEqual   2000000000           0.70 ns/op
BenchmarkIntMapAccess   500000000            5.22 ns/op
BenchmarkReflectTypeMapAccess   50000000     57.6 ns/op
BenchmarkIntMapAccessMiss   100000000           16.4 ns/op
BenchmarkReflectTypeMapAccessMiss   50000000    58.3 ns/op

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
Linux 3.8.0-27-generic #40-Ubuntu SMP Tue Jul 9 00:17:05 UTC 2013 x86_64 x86_64 x86_64
GNU/Linux

Which version are you using?  (run 'go version')
go version devel +21ae2c5817da Fri Aug 09 23:23:34 2013 +1000 linux/amd64


Please provide any additional information below.
@ugorji
Copy link
Contributor Author

ugorji commented Aug 11, 2013

Comment 1:

Groups discussion leading to this is at:
https://groups.google.com/d/msg/golang-dev/Oik3353DJ2w/aNxNhwC9J_kJ

@cznic
Copy link
Contributor

cznic commented Aug 11, 2013

Comment 2:

Seems like a duplicate of #6106 to me. Merge?

@robpike
Copy link
Contributor

robpike commented Aug 12, 2013

Comment 3:

Status changed to Duplicate.

Merged into issue #6106.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants