I need to speed up downloading a large file and I'm using multiple connections for that. I'm using a single goroutine with access to disk and it receives data from multiple goroutines using a channel, as I was advised here.
file, _ := os.Create(filename)
down.destination = file
for info := range down.copyInfo {
down.destination.Seek(info.start, 0)
io.CopyN(down.destination, info.from, info.length)
}
}
The problem is, seeking, when used repeatedly, on a large file, seems to make the operation slower. When info.length
is larger, it has to seek less number of times, and it seems to do the job faster. But I need to make info.length
smaller. Is there a way to make seeking faster? Or should I just download each part to separate temp files and concatenate them at last?