]> Cypherpunks repositories - gostls13.git/commit
runtime: allocate maps' first bucket table lazily
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 27 Mar 2013 23:28:51 +0000 (16:28 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 27 Mar 2013 23:28:51 +0000 (16:28 -0700)
commit5b3ff61be63c87ff3e85609c774143b63e762f4b
treee5b903d31a621c5aa9d728624bf6f1deffeb009e
parentb735eeb323ecae3769e094045e7a908390e1f32f
runtime: allocate maps' first bucket table lazily

Motivated by garbage profiling in HTTP benchmarks. This
changes means new empty maps are just one small allocation
(the HMap) instead the HMap + the relatively larger h->buckets
allocation. This helps maps which remain empty throughout
their life.

benchmark               old ns/op    new ns/op    delta
BenchmarkNewEmptyMap          196          107  -45.41%

benchmark              old allocs   new allocs    delta
BenchmarkNewEmptyMap            2            1  -50.00%

benchmark               old bytes    new bytes    delta
BenchmarkNewEmptyMap          195           50  -74.36%

R=khr, golang-dev, r
CC=golang-dev
https://golang.org/cl/7722046
src/pkg/runtime/hashmap.c
src/pkg/runtime/map_test.go