about summary refs log tree commit homepage
path: root/lib/PublicInbox/Qspawn.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-07-09 03:18:35 +0000
committerEric Wong <e@80x24.org>2016-07-09 03:20:25 +0000
commit2c972f3d70caf99488fff300341450e48be6ebf1 (patch)
tree066ba4c048b2fb64c271de1bc8096cdca46551ec /lib/PublicInbox/Qspawn.pm
parentf89bd1444a595b569606679293d2d01b0b7a049e (diff)
downloadpublic-inbox-2c972f3d70caf99488fff300341450e48be6ebf1.tar.gz
Currently only for git-http-backend use, this allows limiting
the number of spawned processes per-inbox or by group, if there
are multiple large inboxes amidst a sea of small ones.

For example, a "big" repo limiter could be used for big inboxes:
which would be shared between multiple repos:

[limiter "big"]
	max = 4
[publicinbox "git"]
	address = git@vger.kernel.org
	mainrepo = /path/to/git.git
	; shared limiter with giant:
	httpbackendmax = big
[publicinbox "giant"]
	address = giant@project.org
	mainrepo = /path/to/giant.git
	; shared limiter with git:
	httpbackendmax = big

; This is a tiny inbox, use the default limiter with 32 slots:
[publicinbox "meta"]
	address = meta@public-inbox.org
	mainrepo = /path/to/meta.git
Diffstat (limited to 'lib/PublicInbox/Qspawn.pm')
-rw-r--r--lib/PublicInbox/Qspawn.pm7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/PublicInbox/Qspawn.pm b/lib/PublicInbox/Qspawn.pm
index cc9c340d..697c55a1 100644
--- a/lib/PublicInbox/Qspawn.pm
+++ b/lib/PublicInbox/Qspawn.pm
@@ -47,7 +47,7 @@ sub start {
         my ($self, $limiter, $cb) = @_;
         $self->{limiter} = $limiter;
 
-        if ($limiter->{running} < $limiter->{limit}) {
+        if ($limiter->{running} < $limiter->{max}) {
                 _do_spawn($self, $cb);
         } else {
                 push @{$limiter->{run_queue}}, [ $self, $cb ];
@@ -59,9 +59,10 @@ use strict;
 use warnings;
 
 sub new {
-        my ($class, $limit) = @_;
+        my ($class, $max) = @_;
         bless {
-                limit => $limit || 1,
+                # 32 is same as the git-daemon connection limit
+                max => $max || 32,
                 running => 0,
                 run_queue => [],
         }, $class;