Go Conference 2014 spring 参加メモ

GoConに行ってきた。

Go tutorial (@tenntenn)


Go: 90% Perfect, 100% of the time (@bradfitz)

Cons

  • no more threads, no more callbacks
  • readable, top-down code
  • so easy to write server
  • os/exec package & goroutines で shell script を置き換える

Go built-in tools

  • testing
  • benchmarking
  • profiling
  • huge standard library
  • "go get"
  • godoc
  • fofmt, goimports
  • race detector
  • static binaries

Why isn't Go perfect?

  • No generics
  • Data races can happen
  • Code generation
    • gccgo generates very good code
  • Compiling to JavaScript isn't yet great
  • Limited Mobile Support
  • Embedding Go in C/C++/Java/etc
  • Shared libraries
  • Garbage collector
  • Hot stack splits

Goの勉強におすすめ


社内システムをGoで書き直した話 App EngineアプリのPythonからGoへの移行 (@rui314)

Goによるリライト

  • Pythonに比べてライン数1.3倍。閉じ括弧の分くらいしか増えなかった
  • 標準の net/http, http template だけで十分だった

移行の効果

  • CPUとメモリ使用量が減少
  • Goの勉強になった
  • 静的な型付けによる安心感


Five things that make Go fast (@davecheney)

Why choose Go?

  • Concurrency
  • Ease of deployment
  • Performance

一、 Values

  • Go lets you create compact data structures, avoiding unnecessary indirection.
  • Compact data structures utilise the cache better
  • Better cache utilisation leads to better performance

二、 Inliking

  • The Go compiler can automatically inline functions across files and even across packages.
  • Dead code elimination

三、 Escape analysis

  • compilerが参照を解析してstackに置くかheapに置くか決める

四、 Goroutine

  • goroutine scheduling points
    • channel sending and receiving
    • go statement
    • blocking syscall
    • Garbage collection

五、 Segmented and copying stacks

  • goroutine stacks have no guard pages

A few Go 1.3

  • Copying Stacks
  • Precise GC
  • Linker improvements
  • crypto improvements
  • Race detector is 40% faster
  • Small improvements
    • sync.Pool
    • Defer is more effcient


Go in Production At Mackerel.io (@stanaka)



Why Go ?

  • need to support various environment -> cross-compiler, few dependency
  • easy setup -> one binary
  • works quietly as possible -> small footprint
  • 文字列操作はPerl, Rubyが懐かしい

Multi architecture

Build (Compile)

  • use Makefile
  • embed GITCOMMIT and VERSION

Pros / Cons

  • Pros
    • Channel and goroutines is GREAT
    • Easy to support various architectures
  • Cons
    • String processing (parsing/proc/...) is annoying...


お仕事とgolang (@rosylilly)

  • go get : GOPATHの中にあると新たにfetchが行われない -> go get -u
  • gondler : ruby gemsで配布する
    • gom(@mattn): pure Go
  • archive/zip には地雷がある


300万人をGoで捌いた話(@y_matsuwitter)

  • ほぼ素のnet/http
  • m1.large で 2000req/sec
  • トラフィックの90%をGoで処理させている
  • サーバ周り:net/http + gorilla/mux
  • DB周り:sql + Gorp

Goroutineパターン

  • Goroutine as Goroutine
  • Goroutine as CacheDB
    • Redisの課題を解決
  • Goroutine as Message Queue
    • Channelをキューとして使う


Go駆動開発で超速Pushエンジンを作った話 (@plan9user)

  • net/rpcパッケージは柔軟

メリット

  • 環境構築が簡単
    • バイナリだけで動作する -> 本番環境でライブラリ管理が不要
  • WindowsでもLinuxでも動作する


pt & Goroutines (@monochromegane)



  • Goroutine & Channel

GOMAXPROCS

  • Goroutineの並列度
    • デフォルトは1
    • runtime.NumCPU() でコア数を取得
    • runtime.GOMAXPROCS() で並列度を設定


Martini (@_yosssi)


ik in action (moriyoshi)

  • ik
  • features of ik
    • Small memory footprint comparing to the bare fluentd set-up
    • Build-in scoreboard feature
    • Can run on Windows out-of-the-box


まとめ

  • 標準ライブラリが充実してて素で十分足りる(net/http等)
  • 様々なアーキテクチャをサポートしててportabilityが高い
  • small footprint
  • Goroutine + Channel は強力