-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Make LFS http_client parallel within a batch. #32369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
4653cad
dfe8978
3a5889c
906c3fd
c78892e
02d55ff
f903f76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,8 @@ var LFS = struct { | |
|
||
// LFSClient represents configuration for Gitea's LFS clients, for example: mirroring upstream Git LFS | ||
var LFSClient = struct { | ||
BatchSize int `ini:"BATCH_SIZE"` | ||
BatchSize int `ini:"BATCH_SIZE"` | ||
BatchOperationConcurrency int `ini:"BATCH_OPERATION_CONCURRENCY"` | ||
}{} | ||
|
||
func loadLFSFrom(rootCfg ConfigProvider) error { | ||
|
@@ -66,6 +67,11 @@ func loadLFSFrom(rootCfg ConfigProvider) error { | |
LFSClient.BatchSize = 20 | ||
} | ||
|
||
if LFSClient.BatchOperationConcurrency < 1 { | ||
// match the default git-lfs's `lfs.concurrenttransfers` | ||
LFSClient.BatchOperationConcurrency = 3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the default in lfs client is actually 8, not 3: https://github.com/git-lfs/git-lfs/blob/main/lfshttp/client.go#L89 , but I've documented what you set here: https://gitea.com/gitea/docs/pulls/88 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch .... actually there are different documents (I read an out-dated one) .... the default value also ever changed. 😅 The new document: https://github.com/git-lfs/git-lfs/blob/main/docs/man/git-lfs-config.adoc also says 8 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will update it to 8 and update the documents. -> Use 8 as default value for git lfs concurrency #32421 Thank you very much. |
||
} | ||
|
||
LFS.HTTPAuthExpiry = sec.Key("LFS_HTTP_AUTH_EXPIRY").MustDuration(24 * time.Hour) | ||
|
||
if !LFS.StartServer || !InstallLock { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thing, I do not think "batch size" means "concurrency limit" in this case. If I understand correctly:
Maybe "batch size" could be 100 or 1000 without causing problem, but "concurrency limit" should be much smaller, eg: 5 or 10. A lot of connections to a LFS server might trigger their rate-limit protection, or be considered as somewhat DoS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm always in favor of making things more configurable, however as an administrator I think most of the time you would want
[lfs_client].BATCH_SIZE
= (the number of concurrent threads for upload/download within a batch). I'm happy to add a new config though, what should we call it and what should its default be?[lfs_client].BATCH_MAX_THREADS
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
[lfs_client].MAX_OPERATION_CONCURRENCY
? (since there is no "thread" concept in Golang)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair, how about
[lfs_client].BATCH_OPERATION_CONCURRENCY
, as I feel there may be other single-threaded operations still in this code that we might want configs for then, and this is specific to lfs client batch operations? I updated this branch with that config, and defaulted it to what[lfs_client].BATCH_SIZE
if unset or <1There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to match the default git-lfs's behavior:
https://github.com/git-lfs/git-lfs/blob/4cca3f8e7d77c5b86cdfe34c2e6bba2126e3d5cd/docs/man/git-lfs-config.5.ronn#L25-L33