git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Limit file descriptors used by packs

From
Shawn O. Pearce <spearce@spearce.org>
Date
Feb 28, 2011, 20:47 UTC
Message-ID
<20110228204727.GB26052@spearce.org>
In-Reply-To
<7vwrkjhp27.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> wrote:
Show 6 quoted lines
> "Shawn O. Pearce" <spearce@spearce.org> writes:
> 
> > ...  The output file is opened by pack-objects after
> > object enumeration and delete compression are done, ...
> 
> s/delete/deflate/, I guess.
s/delete/delta/ is what I meant. "Compressing objects" is the
delta compression phase. The fact that we save some small deltas in
deflated format during this phase is an uninteresting implementation
detail not worth mentioning in the comments.
 
Show 18 quoted lines
> > diff --git a/sha1_file.c b/sha1_file.c
> > index d949b35..8863ff6 100644
> > --- a/sha1_file.c
> > +++ b/sha1_file.c
> > @@ -708,9 +713,35 @@ static int open_packed_git_1(struct packed_git *p)
> >  	if (!p->index_data && open_pack_index(p))
> >  		return error("packfile %s index unavailable", p->pack_name);
> >  
> > +	if (!pack_max_fds) {
> > + ...
> > +		if (lim.rlim_cur < lim.rlim_max) {
> > +			lim.rlim_cur = lim.rlim_max;
> > +			if (!setrlimit(RLIMIT_NOFILE, &lim))
> > +				max_fds = lim.rlim_max;
> > +		}
> 
> This is somewhat questionable, isn't it?  We don't know why the user chose
> to ulimit the process yet forcibly bust that limit without telling him?
Maybe you are right.

In network server code is somewhat common to push the rlim_cur to rlim_max if its not already there, since you might need to use a lot of fds to handle a lot of concurrent clients. So habit sort of caused me to just do this out of instinct.

In this particular part of C Git, if we are bumping up against the hard pack_max_fds limit we're already into some pretty difficult computation. Trying to push the rlimit higher in order to avoid close/open calls as we cycle through fds isn't really going to make a huge difference on end-user latency for the command to finish its task. So maybe we are better off honoring the rlim_cur that we inherited from the user/environment.

I'll respin a v2 for you.
-- 
Shawn.
Previous: Junio C HamanoNext: Shawn O. Pearce
Message 5 of 10 in “Limit file descriptors used by packs”
  1. Limit file descriptors used by packsShawn O. Pearce, Feb 28, 2011
  2. Bernhard R. LinkFeb 28, 2011
  3. Shawn O. PearceFeb 28, 2011
  4. Junio C HamanoFeb 28, 2011
  5. Shawn O. PearceFeb 28, 2011
  6. Limit file descriptors used by packsShawn O. Pearce, Feb 28, 2011
  7. Erik Faye-LundFeb 28, 2011
  8. Junio C HamanoMar 1, 2011
  9. Shawn PearceMar 1, 2011
  10. 2/1 sha1_file.c: Don't retain open fds on small packsShawn O. Pearce, Mar 2, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.