Last active
August 29, 2015 14:24
-
-
Save najeira/099756882831b32b2e7e to your computer and use it in GitHub Desktop.
fluent-logger-golang 修正メモ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 課題 | |
現在の実装では、送信 `f.conn.Write` の間はロックを獲得しているので、バッファ `pending` への書き込みをブロックする。ネットワークの送信は時間がかかるので、書き込みのパフォーマンスも出ない。 | |
## 対策 | |
Write ではロックを獲得しないようにする。 | |
Write の前に送信するバッファを取得し、書き込み側が違うバッファを使うように差し替える。 | |
また、Write 自体も別のgoroutineで実施する(そうでないと、ロックを回避したのに結局ブロックする)。 | |
## goroutine | |
エラー時には、リトライのために送信待ちの先頭に戻す必要がある。 | |
送信の順序を守る必要があるので、複数のWriteが同時に走ってはならない。 | |
よって、goroutineがひとつであることを確実にする。 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment