]> Cypherpunks repositories - gostls13.git/commit
[dev.garbage] runtime: add bit and cache ctz64 (count trailing zero)
authorRick Hudson <rlh@golang.org>
Wed, 24 Feb 2016 19:36:30 +0000 (14:36 -0500)
committerRick Hudson <rlh@golang.org>
Wed, 27 Apr 2016 21:54:54 +0000 (21:54 +0000)
commit4093481523b1e064e998d5d586276db45f4d11a7
tree29903ce5306ba6185b6e9f0e2bc4cead5c64d31c
parent44fe90d0b393c961e3fb1b4c37e93ce268da46bc
[dev.garbage] runtime: add bit and cache ctz64 (count trailing zero)

Add to each span a 64 bit cache (allocCache) of the allocBits
at freeindex. allocCache is shifted such that the lowest bit
corresponds to the bit freeindex. allocBits uses a 0 to
indicate an object is free, on the other hand allocCache
uses a 1 to indicate an object is free. This facilitates
ctz64 (count trailing zero) which counts the number of 0s
trailing the least significant 1. This is also the index of
the least significant 1.

Each span maintains a freeindex indicating the boundary
between allocated objects and unallocated objects. allocCache
is shifted as freeindex is incremented such that the low bit
in allocCache corresponds to the bit a freeindex in the
allocBits array.

Currently ctz64 is written in Go using a for loop so it is
not very efficient. Use of the hardware instruction will
follow. With this in mind comparisons of the garbage
benchmark are as follows.

1.6 release        2.8 seconds
dev:garbage branch 3.1 seconds.

Profiling shows the go implementation of ctz64 takes up
1% of the total time.

Change-Id: If084ed9c3b1eda9f3c6ab2e794625cb870b8167f
Reviewed-on: https://go-review.googlesource.com/20200
Reviewed-by: Austin Clements <austin@google.com>
src/runtime/malloc.go
src/runtime/mbitmap.go
src/runtime/mcentral.go
src/runtime/mgcsweep.go
src/runtime/mheap.go