innocent-team / isucon10q

isucon10
0 stars 0 forks source link

Golang profiler #6

Open wass88 opened 4 years ago

wass88 commented 4 years ago

https://gist.github.com/catatsuy/e627aaf118fbe001f2e7c665fda48146

wass88 commented 4 years ago

image 便利そう

import "github.com/pkg/profile"
defer profile.Start(profile.ProfilePath("/home/isucon/profile")).Stop()
wass88 commented 4 years ago

AWS:XRayすごいな https://sfujiwara.hatenablog.com/entry/analyze-isucon8-by-xray

image

wass88 commented 4 years ago

X-Ra SDK for Go そんなに大変じゃなさそう https://docs.aws.amazon.com/ja_jp/xray/latest/devguide/xray-sdk-go-configuration.html

設定の例:

{
  "version": 2,
  "rules": [
    {
      "description": "Player moves.",
      "host": "*",
      "http_method": "*",
      "url_path": "/api/move/*",
      "fixed_target": 0,
      "rate": 0.05
    }
  ],
  "default": {
    "fixed_target": 1,
    "rate": 0.1
  }
}
wass88 commented 4 years ago

発行されたSQLをstdoutにproxy https://github.com/shogo82148/go-sql-proxy 実行時間も出る

utgwkk commented 4 years ago

SQLのcaller埋め込む君をaerealさんが書いてたの思い出した go-sql-caller-annotation: GoでSQLに呼び出し元の情報をコメントとして埋め込む - Sexually Knowing

wass88 commented 4 years ago

err漏れとかclose漏れとかの検出器ほしいな

wass88 commented 4 years ago

resp.Body.close忘れるとTCPのstructが再利用されないらしいので気をつけたい

utgwkk commented 4 years ago

VSCodeで手元でwebappを動かしてブレークポイント仕掛けてコールスタック眺めるなどことができた Image from Gyazo

utgwkk commented 4 years ago

pprofだいたいこの記事を読んだら使い方がわかった http://blog.livedoor.jp/sonots/archives/39879160.html

wass88 commented 4 years ago

image https://blog.golang.org/pprof lineprofはlistコマンドでできる

wass88 commented 4 years ago

X of Y やlistの初め2カラムは

wass88 commented 4 years ago
wass88 commented 4 years ago
    profilePath := fmt.Sprintf("./profile/%s/", time.Now().Format("20060102150405"))
    defer profile.Start(profile.ProfilePath(profilePath)).Stop()