Skip to content

Commit dfe8978

Browse files
committed
fine tune
1 parent 4653cad commit dfe8978

File tree

5 files changed

+17
-13
lines changed

5 files changed

+17
-13
lines changed

custom/conf/app.example.ini

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2642,11 +2642,15 @@ LEVEL = Info
26422642
;; override the azure blob base path if storage type is azureblob
26432643
;AZURE_BLOB_BASE_PATH = lfs/
26442644

2645+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2646+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2647+
;; settings for Gitea's LFS client (eg: mirroring an upstream lfs endpoint)
2648+
;;
26452649
;[lfs_client]
2646-
;; When mirroring an upstream lfs endpoint, limit the number of pointers in each batch request to this number
2650+
;; Limit the number of pointers in each batch request to this number
26472651
;BATCH_SIZE = 20
2648-
;; When mirroring an upstream lfs endpoint, limit the number of concurrent upload/download operations within a batch
2649-
;BATCH_OPERATION_CONCURRENCY = 20
2652+
;; Limit the number of concurrent upload/download operations within a batch
2653+
;BATCH_OPERATION_CONCURRENCY = 3
26502654

26512655
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26522656
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

modules/lfs/http_client.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,10 @@ func (c *HTTPClient) performOperation(ctx context.Context, objects []Pointer, dc
137137
}
138138

139139
errGroup, groupCtx := errgroup.WithContext(ctx)
140-
errGroup.SetLimit(setting.LFSClient.BatchConcurrency)
140+
errGroup.SetLimit(setting.LFSClient.BatchOperationConcurrency)
141141
for _, object := range result.Objects {
142142
errGroup.Go(func() error {
143-
err := performSingleOperation(groupCtx, object, dc, uc, transferAdapter)
144-
return err
143+
return performSingleOperation(groupCtx, object, dc, uc, transferAdapter)
145144
})
146145
}
147146

modules/lfs/http_client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ func TestHTTPClientDownload(t *testing.T) {
251251
"dummy": dummy,
252252
},
253253
}
254-
setting.LFSClient.BatchConcurrency = 1
254+
setting.LFSClient.BatchOperationConcurrency = 1
255255

256256
err := client.Download(context.Background(), []Pointer{p}, func(p Pointer, content io.ReadCloser, objectError error) error {
257257
if objectError != nil {

modules/setting/lfs.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ var LFS = struct {
2828

2929
// LFSClient represents configuration for Gitea's LFS clients, for example: mirroring upstream Git LFS
3030
var LFSClient = struct {
31-
BatchSize int `ini:"BATCH_SIZE"`
32-
BatchConcurrency int `ini:"BATCH_OPERATION_CONCURRENCY"`
31+
BatchSize int `ini:"BATCH_SIZE"`
32+
BatchOperationConcurrency int `ini:"BATCH_OPERATION_CONCURRENCY"`
3333
}{}
3434

3535
func loadLFSFrom(rootCfg ConfigProvider) error {
@@ -67,8 +67,9 @@ func loadLFSFrom(rootCfg ConfigProvider) error {
6767
LFSClient.BatchSize = 20
6868
}
6969

70-
if LFSClient.BatchConcurrency < 1 {
71-
LFSClient.BatchConcurrency = LFSClient.BatchSize
70+
if LFSClient.BatchOperationConcurrency < 1 {
71+
// match the default git-lfs's `lfs.concurrenttransfers`
72+
LFSClient.BatchOperationConcurrency = 3
7273
}
7374

7475
LFS.HTTPAuthExpiry = sec.Key("LFS_HTTP_AUTH_EXPIRY").MustDuration(24 * time.Hour)

modules/setting/lfs_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ BATCH_SIZE = 0
114114
assert.NoError(t, loadLFSFrom(cfg))
115115
assert.EqualValues(t, 100, LFS.MaxBatchSize)
116116
assert.EqualValues(t, 20, LFSClient.BatchSize)
117-
assert.EqualValues(t, 20, LFSClient.BatchConcurrency)
117+
assert.EqualValues(t, 20, LFSClient.BatchOperationConcurrency)
118118

119119
iniStr = `
120120
[lfs_client]
@@ -126,5 +126,5 @@ BATCH_OPERATION_CONCURRENCY = 10
126126

127127
assert.NoError(t, loadLFSFrom(cfg))
128128
assert.EqualValues(t, 50, LFSClient.BatchSize)
129-
assert.EqualValues(t, 10, LFSClient.BatchConcurrency)
129+
assert.EqualValues(t, 10, LFSClient.BatchOperationConcurrency)
130130
}

0 commit comments

Comments
 (0)