]> Cypherpunks repositories - gostls13.git/commit
runtime: do not scan maps when k/v do not contain pointers
authorDmitry Vyukov <dvyukov@google.com>
Mon, 26 Jan 2015 18:04:41 +0000 (21:04 +0300)
committerDmitry Vyukov <dvyukov@google.com>
Tue, 27 Jan 2015 17:47:49 +0000 (17:47 +0000)
commit85e7bee19f9f26dfca414b1e9054e429c448b14f
treea16c44c29fb85c8e2280b693d6abedea87b9e484
parent561ce92fa060f746a58c7301138f145632e79294
runtime: do not scan maps when k/v do not contain pointers

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/3288
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/gc/reflect.c
src/reflect/type.go
src/runtime/hashmap.go