Skip to content

runtime: GC pause on Go 1.5 is much longer than Go 1.4 when there is a map with lots of entries. #10986

Closed
@coocood

Description

@coocood

Go version is 1.4.2 and Go devel +80864cf Fri May 29 04:33:15 2015 +0000.
OS is linux/amd64.

GC pause time is about 600ms on Go 1.5 and 300ms on Go 1.4.

Sample code to test GC pause time.

package main

import (
    "fmt"
    "runtime"
    "runtime/debug"
    "time"
)

func GCPause() time.Duration {
    runtime.GC()
    var stats debug.GCStats
    debug.ReadGCStats(&stats)
    return stats.Pause[0]
}

func main() {
    n := 3000 * 1000
    m := make(map[string][]byte)
    for i := 0; i < n; i++ {
        key := fmt.Sprintf("key%v", i)
        val := make([]byte, 10)
        m[key] = val
    }
    fmt.Println("GC pause with 3 million map entries:", GCPause())
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions