From 2c972f3d70caf99488fff300341450e48be6ebf1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 9 Jul 2016 03:18:35 +0000 Subject: www: add configurable limiters 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 --- lib/PublicInbox/Qspawn.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/PublicInbox/Qspawn.pm') 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; -- cgit v1.2.3-24-ge0c7