• Rick Hudson's avatar
    [dev.garbage] runtime: add bit and cache ctz64 (count trailing zero) · 40934815
    Rick Hudson authored
    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/20200Reviewed-by: 's avatarAustin Clements <austin@google.com>
    40934815
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
dev.garbage Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...