• Dmitry Vyukov's avatar
    runtime: do not scan maps when k/v do not contain pointers · 85e7bee1
    Dmitry Vyukov authored
    Currently we scan maps even if k/v does not contain pointers.
    This is required because overflow buckets are hanging off the main table.
    This change introduces a separate array that contains pointers to all
    overflow buckets and keeps them alive. Buckets themselves are marked
    as containing no pointers and are not scanned by GC (if k/v does not
    contain pointers).
    
    This brings maps in line with slices and chans -- GC does not scan
    their contents if elements do not contain pointers.
    
    Currently scanning of a map[int]int with 2e8 entries (~8GB heap)
    takes ~8 seconds. With this change scanning takes negligible time.
    
    Update #9477.
    
    Change-Id: Id8a04066a53d2f743474cad406afb9f30f00eaae
    Reviewed-on: https://go-review.googlesource.com/3288Reviewed-by: 's avatarKeith Randall <khr@golang.org>
    85e7bee1
hashmap.go 30 KB