Skip to content

Commit

Permalink
buffer size update based on benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
maorfr committed Dec 4, 2018
1 parent e555c53 commit 125ed43
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Skbn

Skbn is a tool for copying files and directories between Kubernetes and cloud storage providers. It is named after the 1981 video game [Sokoban](https://en.wikipedia.org/wiki/Sokoban).
Skbn uses an in-memory buffer for the copy process, to avoid excessive memory consumption.
Skbn currently supports the following providers:

* AWS S3
Expand Down Expand Up @@ -77,7 +78,7 @@ skbn cp \
```
* `n` is the number of files to be copied in parallel (for full parallelism use 0)

### Set in memory buffer size
### Set in-memory buffer size

Skbn copies files using an in-memory buffer. To control the buffer size:

Expand All @@ -87,7 +88,8 @@ skbn cp \
--dst ... \
--buffer-size <f>
```
* `f` is the in memory buffer size (in GB) to use for files copy. This flag should be used with caution when used in conjunction with `--parallel`
* `f` is the in-memory buffer size (in MB) to use for files copy. This flag should be used with caution when used in conjunction with `--parallel`
* The default value for `buffer-size` is 6.75 MB, and was decided based on benchmark

## Added bonus section

Expand Down
2 changes: 1 addition & 1 deletion cmd/skbn.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func NewCpCmd(out io.Writer) *cobra.Command {
f.StringVar(&c.src, "src", "", "path to copy from. Example: k8s://<namespace>/<podName>/<containerName>/path/to/copyfrom")
f.StringVar(&c.dst, "dst", "", "path to copy to. Example: s3://<bucketName>/path/to/copyto")
f.IntVarP(&c.parallel, "parallel", "p", 1, "number of files to copy in parallel. set this flag to 0 for full parallelism")
f.Float64VarP(&c.bufferSize, "buffer-size", "b", 1, "in memory buffer size (GB) to use for files copy (buffer per file)")
f.Float64VarP(&c.bufferSize, "buffer-size", "b", 6.75, "in memory buffer size (MB) to use for files copy (buffer per file)")

cmd.MarkFlagRequired("src")
cmd.MarkFlagRequired("dst")
Expand Down
2 changes: 1 addition & 1 deletion pkg/skbn/skbn.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func PerformCopy(srcClient, dstClient interface{}, srcPrefix, dstPrefix string,

go func(srcClient, dstClient interface{}, srcPrefix, fromPath, dstPrefix, toPath, currentLinePadded string, totalFiles int) {

newBufferSize := (int64)(bufferSize * 1024 * 1024 * 1024) // may not be super accurate
newBufferSize := (int64)(bufferSize * 1024 * 1024) // may not be super accurate
buf := buffer.New(newBufferSize)
pr, pw := nio.Pipe(buf)

Expand Down

0 comments on commit 125ed43

Please sign in to comment.