]> source.dussan.org Git - gitea.git/commitdiff
Use 8 as default value for git lfs concurrency (#32421)
authorwxiaoguang <wxiaoguang@gmail.com>
Tue, 5 Nov 2024 13:10:57 +0000 (21:10 +0800)
committerGitHub <noreply@github.com>
Tue, 5 Nov 2024 13:10:57 +0000 (13:10 +0000)
custom/conf/app.example.ini
modules/lfs/http_client.go
modules/lfs/http_client_test.go
modules/setting/lfs.go
modules/setting/lfs_test.go

index e080b0be7273398ca8b680b3dfa507be56187568..f201ff1d1998b7f9ec92bd86d977adcdce42f8ea 100644 (file)
@@ -2650,7 +2650,7 @@ LEVEL = Info
 ;; Limit the number of pointers in each batch request to this number
 ;BATCH_SIZE = 20
 ;; Limit the number of concurrent upload/download operations within a batch
-;BATCH_OPERATION_CONCURRENCY = 3
+;BATCH_OPERATION_CONCURRENCY = 8
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
index 411c4248c4aa9c33f853e20aba2116595316bf15..3060e25754cc54f8e4b689950825830db1f16ece 100644 (file)
@@ -136,6 +136,9 @@ func (c *HTTPClient) performOperation(ctx context.Context, objects []Pointer, dc
                return fmt.Errorf("TransferAdapter not found: %s", result.Transfer)
        }
 
+       if setting.LFSClient.BatchOperationConcurrency <= 0 {
+               panic("BatchOperationConcurrency must be greater than 0, forgot to init?")
+       }
        errGroup, groupCtx := errgroup.WithContext(ctx)
        errGroup.SetLimit(setting.LFSClient.BatchOperationConcurrency)
        for _, object := range result.Objects {
index d22735147a55615cfba3ebc5f8677f1558d342d1..aa7e3c45c4dcb80b0590d29499aa9edc156bf62c 100644 (file)
@@ -237,7 +237,7 @@ func TestHTTPClientDownload(t *testing.T) {
                },
        }
 
-       defer test.MockVariableValue(&setting.LFSClient.BatchOperationConcurrency, 3)()
+       defer test.MockVariableValue(&setting.LFSClient.BatchOperationConcurrency, 8)()
        for _, c := range cases {
                t.Run(c.endpoint, func(t *testing.T) {
                        client := &HTTPClient{
@@ -337,7 +337,7 @@ func TestHTTPClientUpload(t *testing.T) {
                },
        }
 
-       defer test.MockVariableValue(&setting.LFSClient.BatchOperationConcurrency, 3)()
+       defer test.MockVariableValue(&setting.LFSClient.BatchOperationConcurrency, 8)()
        for _, c := range cases {
                t.Run(c.endpoint, func(t *testing.T) {
                        client := &HTTPClient{
index 6b54ac0a60d86128fec4821e7e1b3482794d60e5..7f2d0ae15906185e6ada5f3d6b385dbe2153e820 100644 (file)
@@ -68,8 +68,8 @@ func loadLFSFrom(rootCfg ConfigProvider) error {
        }
 
        if LFSClient.BatchOperationConcurrency < 1 {
-               // match the default git-lfs's `lfs.concurrenttransfers`
-               LFSClient.BatchOperationConcurrency = 3
+               // match the default git-lfs's `lfs.concurrenttransfers` https://github.com/git-lfs/git-lfs/blob/main/docs/man/git-lfs-config.adoc#upload-and-download-transfer-settings
+               LFSClient.BatchOperationConcurrency = 8
        }
 
        LFS.HTTPAuthExpiry = sec.Key("LFS_HTTP_AUTH_EXPIRY").MustDuration(24 * time.Hour)
index 471fa8bff3c68a24b38d0b3938c86a0733646151..d27dd7c5bf87f5fecd1cfb0dff297b115175162e 100644 (file)
@@ -114,7 +114,7 @@ BATCH_SIZE = 0
        assert.NoError(t, loadLFSFrom(cfg))
        assert.EqualValues(t, 100, LFS.MaxBatchSize)
        assert.EqualValues(t, 20, LFSClient.BatchSize)
-       assert.EqualValues(t, 3, LFSClient.BatchOperationConcurrency)
+       assert.EqualValues(t, 8, LFSClient.BatchOperationConcurrency)
 
        iniStr = `
 [lfs_client]