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

Re: [PATCH] gitweb: speed up project listing on large work trees by limiting find depth

From
LLLuke Lu <git@vicaya.com>
Date
Oct 17, 2007, 04:19 UTC
Message-ID
<6B74E96C-37ED-4D6A-8A98-C90B61EFA181@vicaya.com>
In-Reply-To
<20071017040028.GT13801@spearce.org>
On Oct 16, 2007, at 9:00 PM, Shawn O. Pearce wrote:
Show 19 quoted lines
> Luke Lu <git@vicaya.com> wrote:
>> Resubmitting patch after passing gitweb regression tests.
> ...
>> @@ -1519,6 +1524,11 @@ sub git_get_projects_list {
>>  				return if (m!^[/.]$!);
>>  				# only directories can be git repositories
>>  				return unless (-d $_);
>> +				# don't traverse too deep (Find is super slow on os x)
>> +				if (($File::Find::name =~ tr!/!!) - $pfxdepth >  
>> $project_maxdepth) {
>> +					$File::Find::prune = 1;
>> +					return;
>> +				}
>
> Thanks.  I'm squashing this into your patch.  I'm not sure what
> the impact is of altering $File::Find::name in the middle of the
> find algorithm and I'm not sure we want to figure that out later.
> We found out the hard way today that altering a non-local'd $_
> in the function is what was causing the breakage.

This is generally a good advice. But tr!/!! doesn't alter the string at all (OK, replicates it), unless you use the /d option. tr/stuff// is an idiom to count stuff. Check perldoc perlop for details. I don't think it's necessary.

Show 18 quoted lines
>
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 48e21da..9f47c3f 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -1525,7 +1525,8 @@ sub git_get_projects_list {
>  				# only directories can be git repositories
>  				return unless (-d $_);
>  				# don't traverse too deep (Find is super slow on os x)
> -				if (($File::Find::name =~ tr!/!!) - $pfxdepth >  
> $project_maxdepth) {
> +				local $_ = $File::Find::name;
> +				if (tr!/!! - $pfxdepth > $project_maxdepth) {
>  					$File::Find::prune = 1;
>  					return;
>  				}
> -- 
> Shawn.
Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 3 of 5 in “gitweb: speed up project listing on large work trees by limiting find depth”
  1. gitweb: speed up project listing on large work trees by limiting find depthLuke Lu, Oct 17, 2007
  2. Shawn O. PearceOct 17, 2007
  3. Luke LuOct 17, 2007
  4. Shawn O. PearceOct 17, 2007
  5. Shawn O. PearceOct 17, 2007

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.