Skip to content

Commit 0de6b85

Browse files
committed
fix
1 parent 79995a8 commit 0de6b85

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

custom/conf/app.example.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,8 +1420,8 @@ LEVEL = Info
14201420
;; Provides the suffix of the default redis/disk unique queue set name - specific queues can be overridden within in their [queue.name] sections.
14211421
;SET_NAME = "_unique"
14221422
;;
1423-
;; Dynamically scale the worker pool to at this many workers
1424-
;MAX_WORKERS = 10
1423+
;; Maximum number of worker go-routines for the queue. Default value is "CpuNum/2" clipped to between 1 and 10.
1424+
;MAX_WORKERS = ; (dynamic)
14251425

14261426
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14271427
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docs/content/administration/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ Configuration at `[queue]` will set defaults for queues with overrides for indiv
488488
- `CONN_STR`: **redis://127.0.0.1:6379/0**: Connection string for the redis queue type. For `redis-cluster` use `redis+cluster://127.0.0.1:6379/0`. Options can be set using query params. Similarly, LevelDB options can also be set using: **leveldb://relative/path?option=value** or **leveldb:///absolute/path?option=value**, and will override `DATADIR`
489489
- `QUEUE_NAME`: **_queue**: The suffix for default redis and disk queue name. Individual queues will default to **`name`**`QUEUE_NAME` but can be overridden in the specific `queue.name` section.
490490
- `SET_NAME`: **_unique**: The suffix that will be added to the default redis and disk queue `set` name for unique queues. Individual queues will default to **`name`**`QUEUE_NAME`_`SET_NAME`_ but can be overridden in the specific `queue.name` section.
491-
- `MAX_WORKERS`: **10**: Maximum number of worker go-routines for the queue.
491+
- `MAX_WORKERS`: **(dynamic)**: Maximum number of worker go-routines for the queue. Default value is "CpuNum/2" clipped to between 1 and 10.
492492

493493
Gitea creates the following non-unique queues:
494494

modules/setting/queue.go

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package setting
55

66
import (
77
"path/filepath"
8+
"runtime"
89

910
"code.gitea.io/gitea/modules/json"
1011
"code.gitea.io/gitea/modules/log"
@@ -25,18 +26,24 @@ type QueueSettings struct {
2526
MaxWorkers int
2627
}
2728

28-
var queueSettingsDefault = QueueSettings{
29-
Type: "level", // dummy, channel, level, redis
30-
Datadir: "queues/common", // relative to AppDataPath
31-
Length: 100, // queue length before a channel queue will block
32-
33-
QueueName: "_queue",
34-
SetName: "_unique",
35-
BatchLength: 20,
36-
MaxWorkers: 10,
37-
}
38-
3929
func GetQueueSettings(rootCfg ConfigProvider, name string) (QueueSettings, error) {
30+
queueSettingsDefault := QueueSettings{
31+
Type: "level", // dummy, channel, level, redis
32+
Datadir: "queues/common", // relative to AppDataPath
33+
Length: 100, // queue length before a channel queue will block
34+
35+
QueueName: "_queue",
36+
SetName: "_unique",
37+
BatchLength: 20,
38+
MaxWorkers: runtime.NumCPU() / 2,
39+
}
40+
if queueSettingsDefault.MaxWorkers < 1 {
41+
queueSettingsDefault.MaxWorkers = 1
42+
}
43+
if queueSettingsDefault.MaxWorkers > 10 {
44+
queueSettingsDefault.MaxWorkers = 10
45+
}
46+
4047
// deep copy default settings
4148
cfg := QueueSettings{}
4249
if cfgBs, err := json.Marshal(queueSettingsDefault); err != nil {

0 commit comments

Comments
 (0)