Integration of Mercurial into LXR

Simon King simon at simonking.org.uk
Wed Dec 19 11:37:31 UTC 2012


On 19 Dec 2012, at 10:50, andre-littoz <page74010-sf at yahoo.fr> wrote:

I'm back and I had time to tackle the directory listing performance issue.

I replaced the query to internal "repo[rev]" and "ctx.manifest()" by a
simple extension that returns a constant list of strings. I still have the
desperately slow retrieval time with the web server (response time is OK
under the shell). But positively, this rules out any problem with internal
hg data structures.

Since my simple extension is only a sequence of
"ui.write('a_file_name\n')", I questioned ui.write processing time when
operating under a web server. I replaced "ui.write" with
"sys.stdout.write". Same slow response time.

I then changed the number of strings returned. It appears that total time
seems to be proportional to the number of strings (~0.5-0.75 seconds per
line!). Response time does not change if only a single string
(concatenation of individual lines) is returned.

I am really puzzled and do not guess where to go. I am suspecting something
wrong in the pipe mechanism between Python (hg) and Perl (LXR) but an
individual file is also read through a pipe (with command "hg cat" or "hg
blame") without any noticeably difference in performance compared to other
storage engines. Moreover, there should be zillions of apps linking Python
and Perl without problem.

My code is very short and, apart from the hg command, is the same as for
Subversion (which works like a charm):
sub getdir {
    my ($self, $pathname, $releaseid) = @_;
    my ($node, @dirs, @files);

    my $hgpath = $pathname;
    $hgpath =~ s,/*$,/,;
    # Paths on the hg command lines must not start with a slash
    # to be relative to 'rootpath'. Changes LXR convention.
    $hgpath =~ s,^/+,,;
    open(DIR, $$self{'hg-cmd'}
                . "ls-onelevel -r \"$releaseid\" \"$hgpath\" |")
    || die ("hg subprocess died unexpectedly: $!");

    while($node = <DIR>) {
        chomp($node); # Remode trailing newline
        if (substr($node, -1) eq '/') {
            push(@dirs, $node)
        } else {
            push(@files, $node)
        }
    }
    closedir(DIR);
    return (sort(@dirs), sort(@files));
}

hg-cmd is equal to 'cd '.$rootpath . ';HGRCPATH='.$rootpath . '/hg.rc hg ',
i.e. change current directory to directory containing .hg and make HGRCPATH
point to the correct configuration file so that my private extension is
enabled.

Can you see a flaw in the above Perl code? Or a misuse in hg-cmd?


Regards,
André



What happens if you replace the call to hg with a call to a simple python
script that just prints some constant strings? (ie. try to eliminate hg as
the source of the problem). Make sure it uses the same interpreter that the
hg command is using.

Simon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20121219/294fabea/attachment-0002.html>


More information about the Mercurial mailing list