Skip to content

Commit

Permalink
Merge pull request #780 from SiaFoundation/chris/download-memory
Browse files Browse the repository at this point in the history
Add memory manager for downloads
  • Loading branch information
ChrisSchinnerl authored Dec 4, 2023
2 parents 9a50459 + db7c42a commit f37012b
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 109 deletions.
3 changes: 2 additions & 1 deletion api/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ type (
}

MemoryResponse struct {
Upload MemoryStatus `json:"upload"`
Download MemoryStatus `json:"download"`
Upload MemoryStatus `json:"upload"`
}

MemoryStatus struct {
Expand Down
1 change: 1 addition & 0 deletions cmd/renterd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ var (
DownloadMaxOverdrive: 5,
DownloadOverdriveTimeout: 3 * time.Second,

DownloadMaxMemory: 1 << 30, // 1 GiB
UploadMaxMemory: 1 << 30, // 1 GiB
UploadMaxOverdrive: 5,
UploadOverdriveTimeout: 3 * time.Second,
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ type (
DownloadOverdriveTimeout time.Duration `yaml:"downloadOverdriveTimeout"`
UploadOverdriveTimeout time.Duration `yaml:"uploadOverdriveTimeout"`
DownloadMaxOverdrive uint64 `yaml:"downloadMaxOverdrive"`
DownloadMaxMemory uint64 `yaml:"downloadMaxMemory"`
UploadMaxMemory uint64 `yaml:"uploadMaxMemory"`
UploadMaxOverdrive uint64 `yaml:"uploadMaxOverdrive"`
AllowUnauthenticatedDownloads bool `yaml:"allowUnauthenticatedDownloads"`
Expand Down
2 changes: 1 addition & 1 deletion internal/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func NewBus(cfg BusConfig, dir string, seed types.PrivateKey, l *zap.Logger) (ht

func NewWorker(cfg config.Worker, b worker.Bus, seed types.PrivateKey, l *zap.Logger) (http.Handler, ShutdownFn, error) {
workerKey := blake2b.Sum256(append([]byte("worker"), seed...))
w, err := worker.New(workerKey, cfg.ID, b, cfg.ContractLockTimeout, cfg.BusFlushInterval, cfg.DownloadOverdriveTimeout, cfg.UploadOverdriveTimeout, cfg.DownloadMaxOverdrive, cfg.UploadMaxMemory, cfg.UploadMaxOverdrive, cfg.AllowPrivateIPs, l)
w, err := worker.New(workerKey, cfg.ID, b, cfg.ContractLockTimeout, cfg.BusFlushInterval, cfg.DownloadOverdriveTimeout, cfg.UploadOverdriveTimeout, cfg.DownloadMaxOverdrive, cfg.DownloadMaxMemory, cfg.UploadMaxMemory, cfg.UploadMaxOverdrive, cfg.AllowPrivateIPs, l)
if err != nil {
return nil, nil, err
}
Expand Down
1 change: 1 addition & 0 deletions internal/testing/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,7 @@ func testWorkerCfg() config.Worker {
BusFlushInterval: testBusFlushInterval,
DownloadOverdriveTimeout: 500 * time.Millisecond,
UploadOverdriveTimeout: 500 * time.Millisecond,
DownloadMaxMemory: 1 << 28, // 256 MiB
UploadMaxMemory: 1 << 28, // 256 MiB
UploadMaxOverdrive: 5,
}
Expand Down
Loading

0 comments on commit f37012b

Please sign in to comment.