Skip to content

Commit 3439c3e

Browse files
authored
fix: interleave the go and cpp log (#46005)
issue: #45640 pr: #46004 Signed-off-by: chyezh <chyezh@outlook.com>
1 parent 7109b20 commit 3439c3e

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

pkg/log/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func (cfg *Config) initialize() {
153153
cfg.AsyncWritePendingLength = 1024
154154
}
155155
if cfg.AsyncWriteBufferSize <= 0 {
156-
cfg.AsyncWriteBufferSize = 1024 * 1024
156+
cfg.AsyncWriteBufferSize = 4 * 1024
157157
}
158158
if cfg.AsyncWriteMaxBytesPerLog <= 0 {
159159
cfg.AsyncWriteMaxBytesPerLog = 1024 * 1024

pkg/util/paramtable/component_param.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,11 +1666,14 @@ The larger the pending length, the more memory is used, the less logging writes
16661666

16671667
l.AsyncWriteBufferSize = ParamItem{
16681668
Key: "log.asyncWrite.bufferSize",
1669-
DefaultValue: "1m",
1669+
DefaultValue: "4k",
16701670
Version: "2.6.7",
16711671
Doc: `The buffer size of the underlying bufio writer.
16721672
The larger the buffer size, the more memory is used,
1673-
but the less the number of writes to the underlying file system.`,
1673+
but the less the number of writes to the underlying file system.
1674+
Because the cpp will print the log message into stdout,
1675+
when the logging is woring with pipe like tty/docker log driver/k8s,
1676+
PIPE_BUF=4096 may interleave the go log and cpp log together, so 4kb is set as default value to avoid this.`,
16741677
Export: false,
16751678
}
16761679
l.AsyncWriteBufferSize.Init(base.mgr)

pkg/util/paramtable/component_param_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func TestComponentParam(t *testing.T) {
163163
assert.Equal(t, "error", Params.AsyncWriteNonDroppableLevel.GetValue())
164164
assert.Equal(t, 1*time.Second, Params.AsyncWriteStopTimeout.GetAsDurationByParse())
165165
assert.Equal(t, 1024, Params.AsyncWritePendingLength.GetAsInt())
166-
assert.Equal(t, int64(1024*1024), Params.AsyncWriteBufferSize.GetAsSize())
166+
assert.Equal(t, int64(4*1024), Params.AsyncWriteBufferSize.GetAsSize())
167167
assert.Equal(t, int64(1024*1024), Params.AsyncWriteMaxBytesPerLog.GetAsSize())
168168
})
169169

0 commit comments

Comments
 (0)