hg serve is soo slow

Martin Scotta martinscotta at gmail.com
Tue Sep 25 16:57:53 CDT 2012


this works fine for me...
the trick is to process buckets 25 dates each time, and delaying the
execution of the rest 10ms which gives some time to the browser to handle
other threads.

Not the best thing, best would be handle these manipulation at backend side.

return function() {
        var ageclass = /\\bage\\b/,
            dateclass = /\\bdate\\b/,
            nodes = document.getElementsByClassName ?
document.getElementsByClassName('age')
                                                    :
document.getElementsByTagName('*'),
            length = nodes.length, i=0;
        // delayed execution for responsiveness
        !function  process() {
            // each time process only some dates
            for (var b = 0; b < 25; b++) {
                var node = nodes[i++];
                // we may destroy nodes as we process them
                if (node && node.textContent) {
                    var classes = node.className;
                    if (document.getElementsByClassName ||
ageclass.test(classes)) {
                        var agevalue = age(node.textContent);
                        if (dateclass.test(classes)){
                            // We want both: date + (age)
                            node.textContent += ' ('+agevalue+')';
                        } else {
                            node.textContent = agevalue;
                        }
                    }
                }
            }
            if (i < length) setTimeout(process, 10);
        }();
    };


 Martin Scotta


On Tue, Sep 25, 2012 at 5:41 PM, Matt Mackall <mpm at selenic.com> wrote:

> On Tue, 2012-09-25 at 12:16 -0300, Martin Scotta wrote:
> > Hi hg dev,
> > With the latest update (version 2.3.1+20120908) the command hg serve
> became
> > completely unusable due to a bad-written javascript function.
> > My browser complains about some function taking too long to finish -- I'm
> > using latest Firefox on a brand new Retina MacBook Pro
> >
> > The function process_dates (mercurial.js) traverses the ENTIRE dom,
>
> Usually, this is fine because pages like the index are very small. But
> apparently on large files (with no dates to process!) this can take
> quite a while. For instance, i18n/ru.po in the Mercurial repo (25k
> lines) takes 9s to fully load, according to Firebug.
>
> --
> Mathematics is the supreme nostalgia of our time.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20120925/3362abbc/attachment.html>


More information about the Mercurial-devel mailing list