SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
What is new in
Go 1.8
@huazhihao
Agenda
● Language
● Runtime
● Standard Library
● Tool Chain
Language
● Conversion ignoring struct tags
● Alias declaration
Conversion ignoring struct tags
type X struct {
Name string
Num int
}
var Y struct {
Name string `json:"name"`
Num int `json:"num"`
}
Alias declaration
type Foo => pkg.Bar
An alternate syntax in 1.9 ?
AliasSpec = identifier "=>" PackageName "." identifier .
const C => pkg.C
type T => pkg.T
var V => pkg.V
func F => pkg.F
Runtime
● gc pause (< 1ms)
● build (15% speedup)
● defer (10%-35% speedup)
● cgo (45% speedup)
GC pause down to 1ms
1.6 40ms
1.5 300ms
STW Stack Rescanning
Replaced by a hybrid write barrier combines:
● a Yuasa-style deletion write barrier
● a Dijkstra-style insertion write barrier
An improved implementation of write barrier merged in dev branch reduces the gc
pause reliably to 100µs(GOMAXPROCS=12).
ARM SSA Support
SSA(Static single assignment) form is widely used in modern compilers
Go didn’t have an SSA representation in its internals because it's derived from an
old C compiler which predated SSA.
SSA was introduced into the x86/64 platforms in Go 1.7 and immediately made
● 5–35% speedup
● 20–30% reduction in binary size
Static single assignment form in 1 minute
y = 1
y = 2
x = y
↓
y1 = 1
y2 = 2
x1 = y2
Benefits
● constant propagation
● value range propagation
● sparse conditional constant propagation
● dead code elimination
● global value numbering
● partial redundancy elimination
● strength reduction
● register allocation
Compile speed comparison
Faster defer
(µs)
Faster cgo
ns/op
Standard Library
● HTTP Graceful Shutdown
● HTTP2 Server Push
● TLS Additions
● SQL Additions
● Inline Slice Sorting
● Import path of context
HTTP Graceful Shutdown
quit := make(chan os.Signal)
signal.Notify(quit, os.Interrupt)
srv := &http.Server{Addr: ":8080", Handler: http.DefaultServeMux}
go func() {
<-quit
log.Println("Shutting down server...")
if err := srv.Shutdown(context.Background()); err != nil {
log.Fatalf("could not shutdown: %v", err)
}
}()
HTTP2 Server Push
http.Handle("/static", http.FileServer(http.Dir("./static")))
http.HandleFunc("/index.html",
func(w http.ResponseWriter, r *http.Request) {
if p, ok := w.(http.Pusher); ok {
p.Push("/static/style.css", nil)
p.Push("/static/image.png", nil)
}
w.Header().Set("Content-Type", "text/html")
w.Write([]byte(`
<link href="/static/style.css" rel="stylesheet" />
<img src="/static/image.png" />`))
})
http.ListenAndServeTLS(":4430", "cert.pem", "key.pem", nil)
Stream Frame
/static/style.css PUSH_PROMISE
/static/image.png PUSH_PROMISE
/index.html HEADERS
/index.html DATA
/static/style.css HEADERS
/static/style.css DATA
/static/image.png HEADERS
/static/image.png DATA
TLS Additions
● Support for ChaCha20-Poly1305 based cipher suites
● CipherSuites automatically selected based on hardware support availability if
not specified
● More flexible config APIs
SQL Additions
● Cancelable queries
ctx, cancel := context.WithCancel(context.Background())
● Visible database types
type RowsColumnTypeDatabaseTypeName interface {
Rows
ColumnTypeDatabaseTypeName(index int) string
}
● Multiple result sets
rows.NextResultSet()
● Ping can hit server
Conn.Ping() or Conn.PingContext(ctx)
● Named parameters
sql.Named("Name", value)
● Transaction isolation
BeginTx(ctx context.Context, opts *TxOptions)
Inline Slice Sorting
sort.Sort:
type ByKey []Item
func (items ByKey) Len() int { …
//Len implementation
}
func (items ByKey) Swap(i, j int) { ...
//Swap implementation
}
func (items ByKey) Less(i, j int) bool { …
//Less implementation
}
sort.Sort(ByKey(items))
sort.Slice:
sort.Slice(items, func(i, j int) bool {
//Less implementation
})
Sorting Benchmark
Import path of context
-import "golang.org/x/net/context"
+import "context"
Fix the import by running below on your code base:
# dry run
go tool fix -diff -force=context PATH
# overwrite
go tool fix -force=context PATH
Tool Chain
● Plugins (Shared libraries)
● Default GOPATH
● go bug
● Smarter go vet
Plugins (Shared libraries)
plugin.go:
package shared
import "fmt"
var V int
func F() { fmt.Printf("Hello, number %dn", V) }
main.go:
package main
import "plugin"
func main() {
p, err := plugin.Open("plugin.so")
v, err := p.Lookup("V")
f, err := p.Lookup("F")
*v.(*int) = 7
f.(func())() // prints "Hello, number 7"
}
plugin.so:
$ go build -buildmode=plugin plugin.go
Default GOPATH
When GOPATH is not defined, the runtime will use:
● $HOME/go on Unix
● %USERPROFILE%go on Windows
go bug
The easiest way to file a new issue:
Run `go bug`
Your browser will open https://github.com/golang/go/issues/new with system
details prefilled
Smarter go vet
package main
import (
"io"
"log"
"net/http"
"os"
)
func main() {
res, err := http.Get("https://golang.org")
defer res.Body.Close()
if err != nil {
log.Fatal(err)
}
io.Copy(os.Stdout, res.Body)
}
Thank you
i@huazhihao.com

Weitere ähnliche Inhalte

Was ist angesagt?

Fluentd v0.12 master guide
Fluentd v0.12 master guideFluentd v0.12 master guide
Fluentd v0.12 master guideN Masahiro
 
VCLをTDDで書いてデプロイする
VCLをTDDで書いてデプロイするVCLをTDDで書いてデプロイする
VCLをTDDで書いてデプロイするKengo HAMASAKI
 
Networking and Go: An Engineer's Journey (Strangeloop 2019)
Networking and Go: An Engineer's Journey (Strangeloop 2019)Networking and Go: An Engineer's Journey (Strangeloop 2019)
Networking and Go: An Engineer's Journey (Strangeloop 2019)Sneha Inguva
 
Rihards Olups - Encrypting Daemon Traffic With Zabbix 3.0
Rihards Olups - Encrypting Daemon Traffic With Zabbix 3.0Rihards Olups - Encrypting Daemon Traffic With Zabbix 3.0
Rihards Olups - Encrypting Daemon Traffic With Zabbix 3.0Zabbix
 
Weave Networking on Docker
Weave Networking on DockerWeave Networking on Docker
Weave Networking on DockerStylight
 
Ethernet Shield
Ethernet ShieldEthernet Shield
Ethernet ShieldTinker
 
LXC on Ganeti
LXC on GanetiLXC on Ganeti
LXC on Ganetikawamuray
 
WebTalk - Implementing Web Services with a dedicated Java daemon
WebTalk - Implementing Web Services with a dedicated Java daemonWebTalk - Implementing Web Services with a dedicated Java daemon
WebTalk - Implementing Web Services with a dedicated Java daemonGeert Van Pamel
 
Micro HTTP Server Implemented in C @ COSCUP 2016
Micro HTTP Server Implemented in C @ COSCUP 2016Micro HTTP Server Implemented in C @ COSCUP 2016
Micro HTTP Server Implemented in C @ COSCUP 2016Jian-Hong Pan
 
Socket programming with php
Socket programming with phpSocket programming with php
Socket programming with phpElizabeth Smith
 
Docker-OVS
Docker-OVSDocker-OVS
Docker-OVSsnrism
 
The Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compilerThe Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compilerVladimir Sedach
 
Pf: the OpenBSD packet filter
Pf: the OpenBSD packet filterPf: the OpenBSD packet filter
Pf: the OpenBSD packet filterGiovanni Bechis
 
Linux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkgLinux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkgKenny (netman)
 
SCaLE 2016 - syslog-ng: From Raw Data to Big Data
SCaLE 2016 - syslog-ng: From Raw Data to Big DataSCaLE 2016 - syslog-ng: From Raw Data to Big Data
SCaLE 2016 - syslog-ng: From Raw Data to Big DataBalaBit
 

Was ist angesagt? (20)

Fluentd v0.12 master guide
Fluentd v0.12 master guideFluentd v0.12 master guide
Fluentd v0.12 master guide
 
gRPC in Go
gRPC in GogRPC in Go
gRPC in Go
 
VCLをTDDで書いてデプロイする
VCLをTDDで書いてデプロイするVCLをTDDで書いてデプロイする
VCLをTDDで書いてデプロイする
 
Networking and Go: An Engineer's Journey (Strangeloop 2019)
Networking and Go: An Engineer's Journey (Strangeloop 2019)Networking and Go: An Engineer's Journey (Strangeloop 2019)
Networking and Go: An Engineer's Journey (Strangeloop 2019)
 
Rihards Olups - Encrypting Daemon Traffic With Zabbix 3.0
Rihards Olups - Encrypting Daemon Traffic With Zabbix 3.0Rihards Olups - Encrypting Daemon Traffic With Zabbix 3.0
Rihards Olups - Encrypting Daemon Traffic With Zabbix 3.0
 
Weave Networking on Docker
Weave Networking on DockerWeave Networking on Docker
Weave Networking on Docker
 
The basics of fluentd
The basics of fluentdThe basics of fluentd
The basics of fluentd
 
Ethernet Shield
Ethernet ShieldEthernet Shield
Ethernet Shield
 
LXC on Ganeti
LXC on GanetiLXC on Ganeti
LXC on Ganeti
 
Fluentd meetup
Fluentd meetupFluentd meetup
Fluentd meetup
 
WebTalk - Implementing Web Services with a dedicated Java daemon
WebTalk - Implementing Web Services with a dedicated Java daemonWebTalk - Implementing Web Services with a dedicated Java daemon
WebTalk - Implementing Web Services with a dedicated Java daemon
 
Micro HTTP Server Implemented in C @ COSCUP 2016
Micro HTTP Server Implemented in C @ COSCUP 2016Micro HTTP Server Implemented in C @ COSCUP 2016
Micro HTTP Server Implemented in C @ COSCUP 2016
 
Haproxy - zastosowania
Haproxy - zastosowaniaHaproxy - zastosowania
Haproxy - zastosowania
 
Socket programming with php
Socket programming with phpSocket programming with php
Socket programming with php
 
Docker-OVS
Docker-OVSDocker-OVS
Docker-OVS
 
The Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compilerThe Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compiler
 
Fluentd introduction at ipros
Fluentd introduction at iprosFluentd introduction at ipros
Fluentd introduction at ipros
 
Pf: the OpenBSD packet filter
Pf: the OpenBSD packet filterPf: the OpenBSD packet filter
Pf: the OpenBSD packet filter
 
Linux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkgLinux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkg
 
SCaLE 2016 - syslog-ng: From Raw Data to Big Data
SCaLE 2016 - syslog-ng: From Raw Data to Big DataSCaLE 2016 - syslog-ng: From Raw Data to Big Data
SCaLE 2016 - syslog-ng: From Raw Data to Big Data
 

Andere mochten auch

Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsLinkedIn
 
Go 1.8 'new' networking features
Go 1.8 'new' networking featuresGo 1.8 'new' networking features
Go 1.8 'new' networking featuresstrikr .
 
Europe ai scaleups report 2016
Europe ai scaleups report 2016Europe ai scaleups report 2016
Europe ai scaleups report 2016Omar Mohout
 
Reflection in Go
Reflection in GoReflection in Go
Reflection in Gostrikr .
 
BLE Beacons & You: Breaking the IoT Barrier #MNSearch
BLE Beacons & You: Breaking the IoT Barrier #MNSearchBLE Beacons & You: Breaking the IoT Barrier #MNSearch
BLE Beacons & You: Breaking the IoT Barrier #MNSearchCasey Markee, MBA
 
UDVDivas Social Media Campaign Report
UDVDivas Social Media Campaign ReportUDVDivas Social Media Campaign Report
UDVDivas Social Media Campaign ReportMindShift Interactive
 
Customs-Trade Partnership Against Terrorism (C-TPAT): Supply Chain Security
Customs-Trade Partnership Against Terrorism (C-TPAT): Supply Chain SecurityCustoms-Trade Partnership Against Terrorism (C-TPAT): Supply Chain Security
Customs-Trade Partnership Against Terrorism (C-TPAT): Supply Chain SecurityLivingston International
 
The 8 Performance Roadblocks Holding Businesses Back and What to Do About Them
The 8 Performance Roadblocks Holding Businesses Back and What to Do About Them The 8 Performance Roadblocks Holding Businesses Back and What to Do About Them
The 8 Performance Roadblocks Holding Businesses Back and What to Do About Them WINNERS-at-WORK Pty Ltd
 
pref_lib_tsubame_coffee_0311
pref_lib_tsubame_coffee_0311pref_lib_tsubame_coffee_0311
pref_lib_tsubame_coffee_0311Tairo Hosokai
 
15 Ideas to Promote Events with Social Media
15 Ideas to Promote Events with Social Media15 Ideas to Promote Events with Social Media
15 Ideas to Promote Events with Social MediaMarie Ennis-O'Connor
 
Posibilidades de avances en Gestión Clínica en el Servicio Murciano de Salud ...
Posibilidades de avances en Gestión Clínica en el Servicio Murciano de Salud ...Posibilidades de avances en Gestión Clínica en el Servicio Murciano de Salud ...
Posibilidades de avances en Gestión Clínica en el Servicio Murciano de Salud ...Jordi Varela
 
WAI-ARIAの考え方と使い方を整理しよう
WAI-ARIAの考え方と使い方を整理しようWAI-ARIAの考え方と使い方を整理しよう
WAI-ARIAの考え方と使い方を整理しようNozomi Sawada
 
Games for Health分野の研究開発事例
Games for Health分野の研究開発事例Games for Health分野の研究開発事例
Games for Health分野の研究開発事例Toru Fujimoto
 
確率論及統計論輪講 精度より成果
確率論及統計論輪講 精度より成果確率論及統計論輪講 精度より成果
確率論及統計論輪講 精度より成果Kiyoshi Ogawa
 
Looking Beyond the SEO Plugin
Looking Beyond the SEO PluginLooking Beyond the SEO Plugin
Looking Beyond the SEO PluginRebecca Gill
 

Andere mochten auch (18)

Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
 
Go 1.8 'new' networking features
Go 1.8 'new' networking featuresGo 1.8 'new' networking features
Go 1.8 'new' networking features
 
Europe ai scaleups report 2016
Europe ai scaleups report 2016Europe ai scaleups report 2016
Europe ai scaleups report 2016
 
Reflection in Go
Reflection in GoReflection in Go
Reflection in Go
 
File Collaboration, at its best
File Collaboration, at its bestFile Collaboration, at its best
File Collaboration, at its best
 
BLE Beacons & You: Breaking the IoT Barrier #MNSearch
BLE Beacons & You: Breaking the IoT Barrier #MNSearchBLE Beacons & You: Breaking the IoT Barrier #MNSearch
BLE Beacons & You: Breaking the IoT Barrier #MNSearch
 
UDVDivas Social Media Campaign Report
UDVDivas Social Media Campaign ReportUDVDivas Social Media Campaign Report
UDVDivas Social Media Campaign Report
 
Customs-Trade Partnership Against Terrorism (C-TPAT): Supply Chain Security
Customs-Trade Partnership Against Terrorism (C-TPAT): Supply Chain SecurityCustoms-Trade Partnership Against Terrorism (C-TPAT): Supply Chain Security
Customs-Trade Partnership Against Terrorism (C-TPAT): Supply Chain Security
 
The 8 Performance Roadblocks Holding Businesses Back and What to Do About Them
The 8 Performance Roadblocks Holding Businesses Back and What to Do About Them The 8 Performance Roadblocks Holding Businesses Back and What to Do About Them
The 8 Performance Roadblocks Holding Businesses Back and What to Do About Them
 
pref_lib_tsubame_coffee_0311
pref_lib_tsubame_coffee_0311pref_lib_tsubame_coffee_0311
pref_lib_tsubame_coffee_0311
 
Editorial Honors for Professional Builder
Editorial Honors for Professional BuilderEditorial Honors for Professional Builder
Editorial Honors for Professional Builder
 
15 Ideas to Promote Events with Social Media
15 Ideas to Promote Events with Social Media15 Ideas to Promote Events with Social Media
15 Ideas to Promote Events with Social Media
 
140 years of gender equality
140 years of gender equality140 years of gender equality
140 years of gender equality
 
Posibilidades de avances en Gestión Clínica en el Servicio Murciano de Salud ...
Posibilidades de avances en Gestión Clínica en el Servicio Murciano de Salud ...Posibilidades de avances en Gestión Clínica en el Servicio Murciano de Salud ...
Posibilidades de avances en Gestión Clínica en el Servicio Murciano de Salud ...
 
WAI-ARIAの考え方と使い方を整理しよう
WAI-ARIAの考え方と使い方を整理しようWAI-ARIAの考え方と使い方を整理しよう
WAI-ARIAの考え方と使い方を整理しよう
 
Games for Health分野の研究開発事例
Games for Health分野の研究開発事例Games for Health分野の研究開発事例
Games for Health分野の研究開発事例
 
確率論及統計論輪講 精度より成果
確率論及統計論輪講 精度より成果確率論及統計論輪講 精度より成果
確率論及統計論輪講 精度より成果
 
Looking Beyond the SEO Plugin
Looking Beyond the SEO PluginLooking Beyond the SEO Plugin
Looking Beyond the SEO Plugin
 

Ähnlich wie Go 1.8 new features including faster GC, SSA, HTTP/2 push and more

REST made simple with Java
REST made simple with JavaREST made simple with Java
REST made simple with Javaelliando dias
 
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰KAI CHU CHUNG
 
Go 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoGo 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoRodolfo Carvalho
 
Protobuf & Code Generation + Go-Kit
Protobuf & Code Generation + Go-KitProtobuf & Code Generation + Go-Kit
Protobuf & Code Generation + Go-KitManfred Touron
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeKAI CHU CHUNG
 
TDC2018SP | Trilha Go - Processando analise genetica em background com Go
TDC2018SP | Trilha Go - Processando analise genetica em background com GoTDC2018SP | Trilha Go - Processando analise genetica em background com Go
TDC2018SP | Trilha Go - Processando analise genetica em background com Gotdc-globalcode
 
Building Go Web Apps
Building Go Web AppsBuilding Go Web Apps
Building Go Web AppsMark
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the wayOleg Podsechin
 
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディングXitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディングscalaconfjp
 
Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Ngoc Dao
 
Introduction To Groovy 2005
Introduction To Groovy 2005Introduction To Groovy 2005
Introduction To Groovy 2005Tugdual Grall
 
Basics of Java Script (JS)
Basics of Java Script (JS)Basics of Java Script (JS)
Basics of Java Script (JS)Ajay Khatri
 
Introduction to Scalding and Monoids
Introduction to Scalding and MonoidsIntroduction to Scalding and Monoids
Introduction to Scalding and MonoidsHugo Gävert
 
Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2Asher Martin
 
お題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part Aお題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part AKazuchika Sekiya
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기NAVER D2
 

Ähnlich wie Go 1.8 new features including faster GC, SSA, HTTP/2 push and more (20)

REST made simple with Java
REST made simple with JavaREST made simple with Java
REST made simple with Java
 
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
 
Go 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoGo 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX Go
 
Protobuf & Code Generation + Go-Kit
Protobuf & Code Generation + Go-KitProtobuf & Code Generation + Go-Kit
Protobuf & Code Generation + Go-Kit
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
 
TDC2018SP | Trilha Go - Processando analise genetica em background com Go
TDC2018SP | Trilha Go - Processando analise genetica em background com GoTDC2018SP | Trilha Go - Processando analise genetica em background com Go
TDC2018SP | Trilha Go - Processando analise genetica em background com Go
 
Building Go Web Apps
Building Go Web AppsBuilding Go Web Apps
Building Go Web Apps
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the way
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
 
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディングXitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
 
Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014
 
cq_cxf_integration
cq_cxf_integrationcq_cxf_integration
cq_cxf_integration
 
Introduction To Groovy 2005
Introduction To Groovy 2005Introduction To Groovy 2005
Introduction To Groovy 2005
 
Azure F#unctions
Azure F#unctionsAzure F#unctions
Azure F#unctions
 
Basics of Java Script (JS)
Basics of Java Script (JS)Basics of Java Script (JS)
Basics of Java Script (JS)
 
Introduction to Scalding and Monoids
Introduction to Scalding and MonoidsIntroduction to Scalding and Monoids
Introduction to Scalding and Monoids
 
Lobos Introduction
Lobos IntroductionLobos Introduction
Lobos Introduction
 
Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2
 
お題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part Aお題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part A
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
 

Kürzlich hochgeladen

Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 

Kürzlich hochgeladen (20)

Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 

Go 1.8 new features including faster GC, SSA, HTTP/2 push and more

  • 1. What is new in Go 1.8 @huazhihao
  • 2. Agenda ● Language ● Runtime ● Standard Library ● Tool Chain
  • 3. Language ● Conversion ignoring struct tags ● Alias declaration
  • 4. Conversion ignoring struct tags type X struct { Name string Num int } var Y struct { Name string `json:"name"` Num int `json:"num"` }
  • 5. Alias declaration type Foo => pkg.Bar An alternate syntax in 1.9 ? AliasSpec = identifier "=>" PackageName "." identifier . const C => pkg.C type T => pkg.T var V => pkg.V func F => pkg.F
  • 6. Runtime ● gc pause (< 1ms) ● build (15% speedup) ● defer (10%-35% speedup) ● cgo (45% speedup)
  • 7. GC pause down to 1ms 1.6 40ms 1.5 300ms
  • 8. STW Stack Rescanning Replaced by a hybrid write barrier combines: ● a Yuasa-style deletion write barrier ● a Dijkstra-style insertion write barrier An improved implementation of write barrier merged in dev branch reduces the gc pause reliably to 100µs(GOMAXPROCS=12).
  • 9. ARM SSA Support SSA(Static single assignment) form is widely used in modern compilers Go didn’t have an SSA representation in its internals because it's derived from an old C compiler which predated SSA. SSA was introduced into the x86/64 platforms in Go 1.7 and immediately made ● 5–35% speedup ● 20–30% reduction in binary size
  • 10. Static single assignment form in 1 minute y = 1 y = 2 x = y ↓ y1 = 1 y2 = 2 x1 = y2 Benefits ● constant propagation ● value range propagation ● sparse conditional constant propagation ● dead code elimination ● global value numbering ● partial redundancy elimination ● strength reduction ● register allocation
  • 14. Standard Library ● HTTP Graceful Shutdown ● HTTP2 Server Push ● TLS Additions ● SQL Additions ● Inline Slice Sorting ● Import path of context
  • 15. HTTP Graceful Shutdown quit := make(chan os.Signal) signal.Notify(quit, os.Interrupt) srv := &http.Server{Addr: ":8080", Handler: http.DefaultServeMux} go func() { <-quit log.Println("Shutting down server...") if err := srv.Shutdown(context.Background()); err != nil { log.Fatalf("could not shutdown: %v", err) } }()
  • 16. HTTP2 Server Push http.Handle("/static", http.FileServer(http.Dir("./static"))) http.HandleFunc("/index.html", func(w http.ResponseWriter, r *http.Request) { if p, ok := w.(http.Pusher); ok { p.Push("/static/style.css", nil) p.Push("/static/image.png", nil) } w.Header().Set("Content-Type", "text/html") w.Write([]byte(` <link href="/static/style.css" rel="stylesheet" /> <img src="/static/image.png" />`)) }) http.ListenAndServeTLS(":4430", "cert.pem", "key.pem", nil) Stream Frame /static/style.css PUSH_PROMISE /static/image.png PUSH_PROMISE /index.html HEADERS /index.html DATA /static/style.css HEADERS /static/style.css DATA /static/image.png HEADERS /static/image.png DATA
  • 17. TLS Additions ● Support for ChaCha20-Poly1305 based cipher suites ● CipherSuites automatically selected based on hardware support availability if not specified ● More flexible config APIs
  • 18. SQL Additions ● Cancelable queries ctx, cancel := context.WithCancel(context.Background()) ● Visible database types type RowsColumnTypeDatabaseTypeName interface { Rows ColumnTypeDatabaseTypeName(index int) string } ● Multiple result sets rows.NextResultSet() ● Ping can hit server Conn.Ping() or Conn.PingContext(ctx) ● Named parameters sql.Named("Name", value) ● Transaction isolation BeginTx(ctx context.Context, opts *TxOptions)
  • 19. Inline Slice Sorting sort.Sort: type ByKey []Item func (items ByKey) Len() int { … //Len implementation } func (items ByKey) Swap(i, j int) { ... //Swap implementation } func (items ByKey) Less(i, j int) bool { … //Less implementation } sort.Sort(ByKey(items)) sort.Slice: sort.Slice(items, func(i, j int) bool { //Less implementation })
  • 21. Import path of context -import "golang.org/x/net/context" +import "context" Fix the import by running below on your code base: # dry run go tool fix -diff -force=context PATH # overwrite go tool fix -force=context PATH
  • 22. Tool Chain ● Plugins (Shared libraries) ● Default GOPATH ● go bug ● Smarter go vet
  • 23. Plugins (Shared libraries) plugin.go: package shared import "fmt" var V int func F() { fmt.Printf("Hello, number %dn", V) } main.go: package main import "plugin" func main() { p, err := plugin.Open("plugin.so") v, err := p.Lookup("V") f, err := p.Lookup("F") *v.(*int) = 7 f.(func())() // prints "Hello, number 7" } plugin.so: $ go build -buildmode=plugin plugin.go
  • 24. Default GOPATH When GOPATH is not defined, the runtime will use: ● $HOME/go on Unix ● %USERPROFILE%go on Windows
  • 25. go bug The easiest way to file a new issue: Run `go bug` Your browser will open https://github.com/golang/go/issues/new with system details prefilled
  • 26. Smarter go vet package main import ( "io" "log" "net/http" "os" ) func main() { res, err := http.Get("https://golang.org") defer res.Body.Close() if err != nil { log.Fatal(err) } io.Copy(os.Stdout, res.Body) }