From 12c856a10cb9c59ae97504ce0fcd9fdb044bdd14 Mon Sep 17 00:00:00 2001 From: Keuin Date: Thu, 15 Sep 2022 01:36:12 +0800 Subject: Use io.CopyN to utilize zero copy technique. --- main.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index c130301..84f8a5c 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,8 @@ import ( "syscall" ) +const defaultDiskBufSize = uint64(1024 * 1024) // 1MiB + var globalConfig *GlobalConfig func getTasks() (tasks []recording.TaskConfig) { @@ -67,7 +69,8 @@ func getTasks() (tasks []recording.TaskConfig) { &argparse.Options{ Required: false, Help: "Specify disk write buffer size (bytes). " + - "The real minimum buffer size is determined by OS", + "The real minimum buffer size is determined by OS. " + + "Setting this to a large value may make stopping take a long time", Default: 4194304, }, ) @@ -129,13 +132,16 @@ func getTasks() (tasks []recording.TaskConfig) { taskCount := len(*rooms) tasks = make([]recording.TaskConfig, taskCount) saveTo := common.Zeroable[string](*saveToPtr).OrElse(".") - diskBufSize := *diskBufSizePtr + diskBufSize := uint64(*diskBufSizePtr) + if *diskBufSizePtr <= 0 { + diskBufSize = defaultDiskBufSize + } for i := 0; i < taskCount; i++ { tasks[i] = recording.TaskConfig{ RoomId: common.RoomId((*rooms)[i]), Transport: recording.DefaultTransportConfig(), Download: recording.DownloadConfig{ - DiskWriteBufferBytes: diskBufSize, + DiskWriteBufferBytes: int64(diskBufSize), SaveDirectory: saveTo, }, } -- cgit v1.2.3