what's new in go 1.5

Download What's new in Go 1.5

If you can't read please download the document

Upload: aaron-taylor

Post on 12-Jan-2017

259 views

Category:

Technology


0 download

TRANSCRIPT

Whats new in Go 1.5Aaron Taylor@[email protected]

as with any new language, lots of gotchas (things you might have heard/read)concurrency single threadedsub-par GCNo dependency managementIve been looking forward to seeing Gos solutions to its initial growing painsGo 1.5 fixes many of them

Package SystemInternal packagesimport disallowed to packages outside the parent of the internal directoryExperimental vendoring supportimport p => import d/vendor/penable with: GO15VENDOREXPERIMENT=1Go 1.4 "Internal" PackagesGo 1.5 Vendor Experiment

Internal Packages: enable the elimination of private duplicate code in the std-libused in appengine libraries

Vendoring: builtin way to manage dependenciesthird party tools will handle creating this structure

src bar main.go vendor golang.org x net context context.go foo internal helper main.go main.go golang.org x net context context.go

src bar bar.go foo internal helper helpme.go foo.goInternal Packages

src foo main.go bar main.go vendor golang.org/x/net/context context.go golang.org/x/net/context context.goVendored Packagesfoo => import golang.org/x/net/contextbar => import bar/vendor/golang.org/x/net/context

Compiler and RuntimeAll C code translated to Goautomated with optimizations using grind, gofmtbuilds 10x slower => 2x slowerJust one compiler now6g, 6a, 6l, 8a, 8g, etc. are all gonenew tooling availabletraceGopherFest 2015: Rob Pike on the move from C to Go in the toolchain

great talk on this by Rob Pikelots of optimizations necessary in changing idiomatic C to idiomatic Gowill make community contributions much easiertools enabled by the new Go runtime:type safetycontiguous stackno strange C compiler optimizations

True ParallelismGOMAXPROCS = number of logical CPUsenabled by goroutine scheduler improvementspreviously, slowdowns were possible when parallelism was increasedGo 1.5 GOMAXPROCS Default

Go 1.5 GOMAXPROCS Default

creates a chain of 100 goroutines connected by channels and times how long it takes an integer message to propagate from one end to the other. ChainBuf uses buffered channels

Go 1.5 GOMAXPROCS Default

prime sieve also uses many goroutines but has more opportunity for parallelism

Go 1.5 GOMAXPROCS Default

There are still programs that do not run as nicely. For example, the Go port of Doug McIlroy's power series program is almost a worst case for GOMAXPROCS > 1: it creates many ephemeral goroutines, arranges the communication pattern in a tree, and has no use for parallelism

GC improvementsMark and sweep GCStop the world => (mostly) concurrent