Go Conference 2014 autumn 参加メモ

Go Conference 2014 autumnに行ってきた。

Simplicity is Complicated (Rob Pike)

  • 可読性
    • 言語の機能が多すぎると、どの機能を使うべきかに時間を取られてしまう
    • 機能は複雑さを増す
    • 可読性は信頼性
  • 正しい言語機能
    • 「隙間を埋める」機能が必要。たとえば解空間を覆う基底ベクトルのようなもの
    • 予想したとおりに作用する直交性
    • 単純さは直交性と予測可能性に依るもの
  • 具象データ型
    • 関数とメソッド
    • interface
    • パッケージ
    • 並行性
  • 単純さは複雑なことだけど戦う価値はある
  • 単純さは設計が難しい
  • 単純さは作るには複雑

Goに入ってはGoに従え (@fumitoshi_ukai)

資料

  • errorチェック
    • regexp.MustCompile() を使っていいのは初期化の時
    • raw string literalで正規表現をよみやすくする
  • 値とerrorを分けてかえす
  • errorの設計
    • panicは使わない
      • 使ってもpackage内にとどめてrecoverしてerrorをかえす
  • 簡潔な名前を使う
    • レシーバ変数は数文字でよい
    • 基本型の引数の場合は、わかりやすい名前に
  • テストコード
    • コメントにAPIの使い方を書くくらいならExampleテスト
  • コメントのつけかた
    • packageコメントを書く
    • Exportしている名前にはコメントを付ける
    • コメントは対象としているものの名前からはじまる文にする
  • APIデザイン
    • APIはシンプルに
      • 返り値は複数つかえるので出力変数としてポインタは使わない
      • slice, map, chan, interfaceへのポインタは使わない
      • エラーはerrorでかえす:panicしない
      • 引数などはinterfaceのほうが組み合わせやすいしテストもしやすい
  • コードはコミュニケーション
  • 明瞭に表現すること


App Engine for Golang performance (@sinmetal)

  • What's Managed VMs?
    • Container of App Engine on the Compute Engine
    • Escape from cage of Google App
    • deploy is verrrrrry slow
    • The min value of the auto-scaling is 1
  • Performance: App Engine for Golang vs App Engine for Java
    • Golang
      • response : 30ms
      • max instance : 20
    • Java
      • 最初はレスポンス悪い
  • Performance: MVMs for Golang
    • Golang
      • max instance : 1
    • Java
      • max instance : 5
      • うまく動かなかった


Golang @ISUCON (@y_matsuwitter)

  • プロセスキャッシュ
    • データをプロセス上に全て保持しておく
    • 永続化は適切なタイミングでRedisに保存なりファイルにdumpなりする
  • syncパッケージ
    • 各種のロックを扱うパッケージ
    • sync.RWMutex
    • sync/atomic
  • タスク分散処理
    • 処理に時間かかるものを並行実行数を制限して実行したい
  • Task Queueing
    • capacity付きのchannelを使う
  • stathat/consistent
    • コンシステントハッシュライブラリ
    • 一定の名前に対して必ず同じ処理先を決定


mackerel-agent徹底解説 (id:Songmu)

  • Why Go?
    • シングルバイナリが吐けるのでセットアップが簡単
    • 常駐プロセスを書くことに向いている
    • フットプリントが小さく監視対象のサーバーのパフォーマンスに影響を及ぼさない

Why my Go program is slow? (@mathane)

  • runtime/pprof
    • Sampling profiler
    • net/http/pprof provides HTTP API for pprof
    • svg出力できる
    • weblist: Go 1.4〜はアセンブラコードも見れる
  • Things makes Go slower
    • GC
    • memcpy
    • function call
  • GC
    • GODEBUG=gctrace=1
    • heap profile with pprof
  • memcpy
    • Choose carefully string or []byte


One Year of Production Go (@ironzeb)

  • Gengo で Go を導入した話
  • 78%のAPIでGoを使っている
  • Quick Wins
    • Run gofmt -s in your build
    • Fix issues with gofmt -w
    • Use go test -race
    • Use goimports
    • Do go vet every now and again


NSQ-Centric Architecture (@grose)

  • What is NSQ
    • NSQ
    • message queue written in Go
    • made by bit.ly


Hacking Go Compiler Internals (@moriyoshit)


LT

nginx-build (@cubicdaiya)


Terraform で始める Go 言語 (@tkak)


ビルドパイプラインツールを Go で書いた話 (@naokiainoya)


go/parser, go/astの話 (@yuroyoro)


Unit-testing programs depend on I/O in Go (@yuya_takeyama)


Distributed Systems (@imkira85)