What else is in Go 1.11?

27 June 2018

Daniel Martí

Go 1.11

Sources:

2

Ports

Dropped:

Minor additions, like -race on linux/ppc64le and -msan on linux/arm64.

riscv and riscv64 reserved as GOARCH values reserved for the future.

3

Tooling (besides modules)

4

Tooling #2 - x/tools/go/packages

A replacement for x/tools/go/loader with several advantages:

5

Tooling #3 - gofmt

var _ = T{
    F1: 1,
    F2: 1,
    VeryLongNameJustBecause: 1,
    F3: 1,
}

The tweaked heuristic now gives us:

var _ = T{
    F1:                      1,
    F2:                      1,
    VeryLongNameJustBecause: 1,
    F3:                      1,
}
6

Tooling #4 - godoc versions for std

7

Tooling #5 - debugging

Optimized binaries now include more accurate info, like:

DWARF sections (debugging info) are now compressed by default

8

Runtime

9

Compiler #1 - indexed export format

--

Juju/c=4/l=4        46.3s ± 4%        38.0s ± 4%  -18.06%  (p=0.001 n=7+7)
Kubelet/c=4/l=4     48.1s ± 2%        39.0s ± 5%  -18.93%  (p=0.002 n=6+6)
10

Compiler #2 - unused type switch variables

func f(v interface{}) {
    switch x := v.(type) {
    }
}
11

Compiler #3 - inlining function calls

-l=4 makes the inlining more agressive, also enabling mid-stack inlining

12

Compiler #4 - map clearing idiom

for k := range m {
    delete(m, k)
}
GoMapClear/Reflexive/1         92.2ns ± 1%  47.1ns ± 2%  -48.89%  (p=0.000 n=9+9)
GoMapClear/Reflexive/10         108ns ± 1%    48ns ± 2%  -55.68%  (p=0.000 n=10+10)
GoMapClear/Reflexive/100        303ns ± 2%   110ns ± 3%  -63.56%  (p=0.000 n=10+10)
GoMapClear/Reflexive/1000      3.58µs ± 3%  1.23µs ± 2%  -65.49%  (p=0.000 n=9+10)
GoMapClear/Reflexive/10000     28.2µs ± 3%  10.3µs ± 2%  -63.55%  (p=0.000 n=9+10)
13

Compiler #5 - slice extension

append(s, make([]T, n)...)
ExtendSlice/IntSlice         103ns ± 4%      57ns ± 4%   -44.55%  (p=0.000 n=18+18)
ExtendSlice/PointerSlice     155ns ± 3%      77ns ± 3%   -49.93%  (p=0.000 n=20+20)
ExtendSlice/NoGrow          50.2ns ± 3%     5.2ns ± 2%   -89.67%  (p=0.000 n=18+18)
14

Compiler #6 - prove pass

The prove pass derives facts from code, to be used to delete unnecessary
branches and bounds checks.

Most importantly, it now recognizes transitive relations:

The bounds check is what panics if the index is out of bounds, so in this case
it can be removed.

15

Standard library highlights #1

Let's begin with some of the most visible changes:

16

Standard library highlights #2

{{ $v := "init" }}
{{ if true }}
    {{ $v = "changed" }}
{{ end }}
v: {{ $v }} {{/* "changed" */}}<Paste>
ioutil.TempFile("", "foo-") // /tmp/foo-123456
ioutil.TempFile("", "foo-*.txt") // /tmp/foo-123456.txt
17

Standard library highlights #3

What about performance?

18

Thank you

Daniel Martí

Use the left and right arrow keys or click the left and right edges of the page to navigate between slides.
(Press 'H' or navigate to hide this message.)