]> Cypherpunks repositories - gostls13.git/commit
runtime: special case copy, equal for one-word interface values
authorKyle Consalus <consalus@gmail.com>
Thu, 26 Aug 2010 17:32:40 +0000 (13:32 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 26 Aug 2010 17:32:40 +0000 (13:32 -0400)
commit4d903504b326bfc0ed23094b6c6af08d1bf112eb
tree1dd97d6753292ccc92b0c04c30ce156d70a2af6b
parentba5b09f78647fe9d27ffd9700c521681c328915e
runtime: special case copy, equal for one-word interface values

Based on the observation that a great number of the types that
are copied or compared in interfaces, maps, and channels are
word-sized, this uses specialized copy and equality functions
for them that use a word instead of 4 or 8 bytes. Seems to yield
0-6% improvements in performance in the benchmarks I've run.
For example, with the regexp benchmarks:

Before:
regexp.BenchmarkLiteral   500000       3.26 µs/op
regexp.BenchmarkNotLiteral    100000      13.67 µs/op
regexp.BenchmarkMatchClass    100000      18.72 µs/op
regexp.BenchmarkMatchClass_InRange    100000      20.04 µs/op
regexp.BenchmarkReplaceAll    100000      27.85 µs/op

After:
regexp.BenchmarkLiteral   500000       3.11 µs/op
regexp.BenchmarkNotLiteral    200000      13.29 µs/op
regexp.BenchmarkMatchClass    100000      17.65 µs/op
regexp.BenchmarkMatchClass_InRange    100000      18.49 µs/op
regexp.BenchmarkReplaceAll    100000      26.34 µs/op

R=rsc
CC=golang-dev
https://golang.org/cl/1967047
src/cmd/gc/go.h
src/cmd/gc/subr.c
src/pkg/runtime/runtime.c
src/pkg/runtime/runtime.h