ioutil.ReadAll and base64 Encoder benchmark
Streamの扱い方 by jun06t を読んだ。
ioutil.ReadAll は io.Reader や io.Writer を使ったときと比べてメモリ効率が良くなく、避けた方が良いみたい。
知らなかった。
資料を参考にしつつ、個人的に気になった base64 encoder のベンチマークを加えて、自分でも試してみた。
結果
[utahta@mbp13 bench]% go version go version go1.8.3 darwin/amd64 # /tmp/image.jpg 300KB [utahta@mbp13 bench]% go test -bench . -benchmem BenchmarkRead1-4 10000 121861 ns/op 1046577 B/op 11 allocs/op BenchmarkRead2-4 50000 37957 ns/op 311456 B/op 3 allocs/op BenchmarkEncode1-4 3000 459245 ns/op 1130656 B/op 5 allocs/op BenchmarkEncode2-4 3000 516458 ns/op 1455392 B/op 13 allocs/op PASS # /tmp/image.jpg 20MB [utahta@mbp13 bench]% go test -bench . -benchmem BenchmarkRead1-4 200 8519747 ns/op 67106875 B/op 17 allocs/op BenchmarkRead2-4 500 3436382 ns/op 20480160 B/op 3 allocs/op BenchmarkEncode1-4 50 32229327 ns/op 75104416 B/op 5 allocs/op BenchmarkEncode2-4 50 34383885 ns/op 94418246 B/op 19 allocs/op PASS
read は、たしかに ioutil.ReadAll を使う理由がないくらい差がある模様。
もしくは ioutil.ReadAll の中身を io.Copy を使うように書きかえたら、みんな幸せになるのでは…?
反面 base64 Encoder は、EncodeToString の方が結果が良かった。
僕の書き方が悪い可能性も大いにあるけど、少なくともこのように書いて得することはなさそう。
tmux 2.4 にしてから日本語まわりの様子がおかしい対策
様子
パッチ
master をインストールしたら再現しなかったので、おそらく道中修正されたのだろうと思い、それっぽいコミットをパッチにして当ててみたところ再現しなくなった。
master を使い続ける選択肢もあったけど、tmuxしれっと設定周りなどに破壊的変更が入る印象なので、できれば穏やかにバージョンアップをしていきたい…。
ソースコード読みきれず他にもバグが含まれているかもしれないけど、いったん良しとした。
作業ログ
homebrew を使っているので brew edit
して以下のように patches を埋め込み再インストールした。
def patches [ "https://gist.githubusercontent.com/utahta/6f14dc33ec0700f3f2f224e0ce84c772/raw/fd87552e02f75013d65783493247315ca1754e8e/tmux-2.4-input.patch", "https://gist.githubusercontent.com/utahta/6f14dc33ec0700f3f2f224e0ce84c772/raw/fd87552e02f75013d65783493247315ca1754e8e/tmux-2.4-screen-write.patch", ] end
git archive を使ってリリース用ファイルをエクスポートする
/var/tmp/junk
にファイルをエクスポートする。
$ git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)
エクスポートしたくないファイルがあるときは .gitattributes
に書いて、git archive
時に --worktree-attributes
オプションを付ける。
$ vim .gitattributes .gitignore export-ignore Makefile export-ignore $ git archive --worktree-attributes --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)