user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH] http: release resources when idle
@ 2016-05-17  8:30  7% Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2016-05-17  8:30 UTC (permalink / raw)
  To: meta

This lets us release old git processes so unlinked packs
(leftover from repacking) can be released.  This may also
be helpful for Xapian as indices get rebuilt for tuning.

For SQLite (msgmap), the there may be no benefit besides
reducing FD pressure.

Followup changes will unify the Inbox and NewsGroup
classes and allow better code-sharing between NNTP and
HTTP classes (as well as the planned POP3 class).
---
 lib/PublicInbox/HTTP.pm | 14 ++++++++++++++
 lib/PublicInbox/WWW.pm  |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm
index bbcb089..1ef3fb3 100644
--- a/lib/PublicInbox/HTTP.pm
+++ b/lib/PublicInbox/HTTP.pm
@@ -24,6 +24,15 @@ use constant {
 	CHUNK_MAX_HDR => 256,
 };
 
+# FIXME: duplicated code with NNTP.pm
+my $WEAKEN = {}; # string(inbox) -> inbox
+my $WEAKTIMER;
+sub weaken_task () {
+	$WEAKTIMER = undef;
+	$_->weaken_all for values %$WEAKEN;
+	$WEAKEN = {};
+}
+
 # Use the same configuration parameter as git since this is primarily
 # a slow-client sponge for git-http-backend
 # TODO: support per-respository http.maxRequestBuffer somehow...
@@ -198,6 +207,11 @@ sub response_write {
 		} else {
 			$self->write(sub { $self->close });
 		}
+		if (my $obj = $env->{'pi-httpd.inbox'}) {
+			# grace period for reaping resources
+			$WEAKEN->{"$obj"} = $obj;
+			$WEAKTIMER ||= Danga::Socket->AddTimer(60, *weaken_task);
+		}
 		$self->{env} = undef;
 	};
 
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index 95288a7..465dcb2 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -129,6 +129,8 @@ sub invalid_inbox {
 	if (defined $obj) {
 		$ctx->{git_dir} = $obj->{mainrepo};
 		$ctx->{git} = $obj->git;
+		# for PublicInbox::HTTP::weaken_task:
+		$ctx->{cgi}->{env}->{'pi-httpd.inbox'} = $obj;
 		$ctx->{-inbox} = $obj;
 		$ctx->{inbox} = $inbox;
 		return;

^ permalink raw reply related	[relevance 7%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-05-17  8:30  7% [PATCH] http: release resources when idle Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).