Closed budougumi0617 closed 1 year ago
https://mobile.twitter.com/mattn_jp/status/1489970495718330369
ちなみに req.Body.Close() をサーバで書いてるコードを稀に見るのだけど、サーバではやる必要ないです。Go の net/http が閉じます。クライアントも Transport 層が閉じます。なので基本必要ない。
めちゃくちゃやってる気がするので直そう…
Go performance from version 1.2 to 1.18 https://benhoyt.com/writings/go-version-performance/
Dumpster diving the Go garbage collector https://blog.px.dev/go-garbage-collector/
縦に長くならない工夫していないな…(自戒) https://zenn.dev/kimuson13/articles/go_table_driven_test
アクターモデルあまりわかっていない。。。 https://viscarra.dev/post/go-generics-actor/
interface{}型はcomparable interfaceを満たさない、と言う扱いになったらしい https://t.co/tPo1TPA6xo
神ドキュメント https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeout contextとの兼ね合いはどうなんだろうな? https://pkg.go.dev/net/http#NewRequestWithContext にもそんなに書いてないな
関数が終わったときからタイムアウトってこう書けるのね。
defer func() {
c.rwc.SetWriteDeadline(time.Now().Add(d))
}()
https://cs.opensource.google/go/go/+/master:src/net/http/server.go;l=958-980;bpv=0;bpt=1
// Read next request from connection.
func (c *conn) readRequest(ctx context.Context) (w *response, err error) {
if c.hijacked() {
return nil, ErrHijacked
}
var (
wholeReqDeadline time.Time // or zero if none
hdrDeadline time.Time // or zero if none
)
t0 := time.Now()
if d := c.server.readHeaderTimeout(); d > 0 {
hdrDeadline = t0.Add(d)
}
if d := c.server.ReadTimeout; d > 0 {
wholeReqDeadline = t0.Add(d)
}
c.rwc.SetReadDeadline(hdrDeadline)
if d := c.server.WriteTimeout; d > 0 {
defer func() {
c.rwc.SetWriteDeadline(time.Now().Add(d))
}()
}
GCはメモリキャパシティよりもストップザ・ワールドのほうのCPU負荷のほうが気になる。
昔の記事だが可視化の話があった。 https://postd.cc/visualising-the-go-garbage-collector/
テストデータをいい感じにつかってくれるやつ https://github.com/bluele/factory-go
起動時のlazy loadで sync.Once
つかえる。
func (s *server) handleTemplate(files string...) http.HandlerFunc {
var (
init sync.Once
tpl *template.Template
tplerr error
)
return func(w http.ResponseWriter, r *http.Request) {
init.Do(func(){
tpl, tplerr = template.ParseFiles(files...)
})
if tplerr != nil {
http.Error(w, tplerr.Error(), http.StatusInternalServerError)
return
}
// use tpl
}
}
とりあえずLocationを作れればいいってときはこっち使うとシステムコール呼ばずに普通の構造体初期化でいい感じ。 https://pkg.go.dev/time#FixedZone
https://go-review.googlesource.com/c/go/+/384235
これで interface{}
は含まなくするってすごいな(なにもわからない)
// comparable is an interface that is implemented by all comparable types
// (booleans, numbers, strings, pointers, channels, arrays of comparable types,
// structs whose fields are all comparable types).
// The comparable interface may only be used as a type parameter constraint,
// not as the type of a variable.
type comparable interface{ comparable }
The comparable interface may only be used as a type parameter constraint, not as the type of a variable.
はどこでやってるんだろうな
The comparable interface may only be used as a type parameter constraint, not as the type of a variable. はどこでやってるんだろうな
cmd/compileのなかかな?と思ったけれど見つからず…
15:00~16:00 @ Zoom, BASE BANK, Inc.
参加者
@budougumi0617 @glassmonkey @daisuzu
お題
ネタ
ネタがなかったら proposal: review meeting minutes をみてみよう!
https://github.com/golang/go/issues/33502