Skip to content

Commit

Permalink
feat(restore): support --transfers=0 for max speed restore and make i…
Browse files Browse the repository at this point in the history
…t default

Our experiments showed that the fastest file download
was achieved for transfers=2*cpu_cnt. In order to make
it easier for the user to use, a new, special value
of --transfers=0 flag will take care of that.
It is set as the default, because we aim to make
not configured restore as fast as possible.
  • Loading branch information
Michal-Leszczynski committed Oct 8, 2024
1 parent b10c5de commit 4ce2f63
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
3 changes: 2 additions & 1 deletion docs/source/sctool/partials/sctool_restore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,10 @@ options:
Timezone of --cron and --window flag values.
The default value is taken from this system, namely 'TZ' envvar or '/etc/localtime' file.
- name: transfers
default_value: "2"
default_value: "0"
usage: |
Sets the amount of file transfers to run in parallel when downloading files from backup location to Scylla node.
Set to 0 for the fastest download (results in setting transfers to 2*node_shard_count).
- name: window
default_value: '[]'
usage: |
Expand Down
3 changes: 2 additions & 1 deletion docs/source/sctool/partials/sctool_restore_update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@ options:
Timezone of --cron and --window flag values.
The default value is taken from this system, namely 'TZ' envvar or '/etc/localtime' file.
- name: transfers
default_value: "2"
default_value: "0"
usage: |
Sets the amount of file transfers to run in parallel when downloading files from backup location to Scylla node.
Set to 0 for the fastest download (results in setting transfers to 2*node_shard_count).
- name: window
default_value: '[]'
usage: |
Expand Down
2 changes: 1 addition & 1 deletion pkg/command/restore/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (cmd *command) init() {
w.Unwrap().StringVarP(&cmd.snapshotTag, "snapshot-tag", "T", "", "")
w.Unwrap().IntVar(&cmd.batchSize, "batch-size", 2, "")
w.Unwrap().IntVar(&cmd.parallel, "parallel", 1, "")
w.Unwrap().IntVar(&cmd.transfers, "transfers", 2, "")
w.Unwrap().IntVar(&cmd.transfers, "transfers", 0, "")
w.Unwrap().BoolVar(&cmd.allowCompaction, "allow-compaction", false, "")
w.Unwrap().BoolVar(&cmd.restoreSchema, "restore-schema", false, "")
w.Unwrap().BoolVar(&cmd.restoreTables, "restore-tables", false, "")
Expand Down
1 change: 1 addition & 0 deletions pkg/command/restore/res.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ parallel: |
transfers: |
Sets the amount of file transfers to run in parallel when downloading files from backup location to Scylla node.
Set to 0 for the fastest download (results in setting transfers to 2*node_shard_count).
allow-compaction: |
Defines if auto compactions should be running on Scylla nodes during restore.
Expand Down
11 changes: 7 additions & 4 deletions pkg/service/restore/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ type Target struct {
locationHosts map[Location][]string `json:"-"`
}

const maxBatchSize = 0
const (
maxBatchSize = 0
maxTransfers
)

func defaultTarget() Target {
return Target{
BatchSize: 2,
Parallel: 0,
Transfers: 2,
Transfers: 0,
Continue: true,
}
}
Expand All @@ -64,8 +67,8 @@ func (t Target) validateProperties() error {
if t.Parallel < 0 {
return errors.New("parallel param has to be greater or equal to zero")
}
if t.Transfers < 1 {
return errors.New("transfers param has to be greater than zero")
if t.Transfers < 0 {
return errors.New("transfers param has to be greater or equal to zero")
}
if t.RestoreSchema == t.RestoreTables {
return errors.New("choose EXACTLY ONE restore type ('--restore-schema' or '--restore-tables' flag)")
Expand Down
8 changes: 6 additions & 2 deletions pkg/service/restore/tables_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,12 @@ func (w *tablesWorker) stageRestoreData(ctx context.Context) error {
}

for _, h := range hosts {
if err := w.client.RcloneSetTransfers(ctx, h, w.target.Transfers); err != nil {
return errors.Wrapf(err, "set transfers on %s to %d", h, w.target.Transfers)
transfers := w.target.Transfers
if transfers == maxTransfers {
transfers = 2 * int(hostToShard[h])
}
if err := w.client.RcloneSetTransfers(ctx, h, transfers); err != nil {
return errors.Wrapf(err, "set transfers on %s to %d", h, transfers)
}
}

Expand Down

0 comments on commit 4ce2f63

Please sign in to comment.