Posts Tagged annotate

v0.5 Release Complete

I’ve finally completed my 0.5 release. This release I tackled an interesting problem with hg annotate. Trying to improve efficiency and loading time of an application isn’t something I had tackled before. It was a good experience trying to figure out the solution to this problem. I’ll be putting up a new patch on the bug page very soon. The following are some of the important links for this release:

View the project page for more details.

EDIT: I’ve posted the patch for this release. Have a look…

, ,

No Comments

v0.5 Release - Running an Experiment

In my last post I revealed my fix for the hg annotate loading issues. My fix reduced the loading time to a relatively reasonable ~8sec considering the fact that currently the loading time is ~20sec. However, it was still bugging me that Mat’s implementation was producing faster loading times than my fix. His implementation is ~1sec faster.

Mat’s Implementation

The problem is that this implementation doesn’t use valid HTML. Mat uses two non-standard tags, x and l#parity#. Although, I must say that this is a very unorthodox and smart solution to this problem:

annotateline = '<l#parity#><x><a href="#url#diff/#node|short#/#file|urlescape#{sessionvars%urlparameter}">#author|obfuscate#@#rev#</a></x><a href="##lineid#" id="#lineid#">#linenumber#</a>#line|escape#</l#parity#>'

Altering Mat’s Code into Valid HTML

As an experiment I decided to test what would happen if I took Mat’s code and replaced the x and l#parity# tags with divs. Would the implemenation still remain as fast? Would it still be faster than mine? The following is the altered code:

annotateline = '<div class="l#parity#"><div class="codeauthor"><a href="#url#diff/#node|short#/#file|urlescape#{sessionvars%urlparameter}">#author|obfuscate#@#rev#</a></div><a class="codeline" href="##lineid#">#linenumber#</a>#line|escape#</div>'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
div.codeauthor { 
    display:inline-block; 
    width:16ch; 
    text-align: right; 
    color:#999999; 
    text-decoration:none;
    margin-right: 25em;
} 
a.codeline { 
    color:#999999; 
    text-decoration:none; 
    margin:0 10px; 
}                                   
div.l0 {
    background-color:#f6f6f0;
}                                                                    
div.l0, div.l1 { 
    display:block; 
}
pre.completecodeline { 
    font-size:12px; 
    line-height:1.4em; 
}
a.codeline:hover,
a.codeline:visited,
a.codeline:active {
    color: #880000;
}

Results

I tried testing the altered code and I was getting a loading time of ~7sec for this cpp file. However, I was never able to get into the ~5sec region which Mat’s original code was sometimes able to achieve. This altered version was only able to reach a minimum time of ~6sec.

The point is that this altered version is a bit faster than my fix but slower than Mat’s original implementation. I compared the file sizes of the 3 versions:

  • My fix: 2.4MB
  • Mat’s Fix:1.8MB
  • Altered version of Mat’s Fix: 2.2MB

It is interesting to note that using div tags instead of an x and l#parity# tag increases the file size by 18%. I don’t know why that happens but somehow the x and l#parity# tags are more efficient than div tags. Nonetheless the reasons don’t matter, the altered version of Mat’s fix seems to be the best solution to this problem at this time.

, , ,

2 Comments

v0.5 Release - My Fix for the hg Annotate Problem

In my last post I had examined a couple of patches that other people had posted for bug 459823. This time I wrote my own code to see if I could make an improvement on what others have done. I did borrow some things but my implementation will be a bit different.

HTML

Instead of using one large table to hold all the rows I’ve decided to use a single div that holds two links and another div:

annotateline = '<a class="codelineauthor" href="#url#diff/#node|short#/#file|urlescape#{sessionvars%urlparameter}">#author|obfuscate#@#rev#</a><a class="codelinenumber" href="##lineid#" id="#lineid#">#linenumber#</a><div class="codeline parity#parity#">#line|escape#</div>'

The HTML is pretty simple, nothing fancy. All the formatting will be done by the CSS instead of a table.

CSS

I’ve decided to place my CSS in the style-gitweb.css style sheet instead of just leaving it in the fileannotate.tmpl file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
a.codelineauthor {
	width: 50ch;
	float: left; 
}
a.codelinenumber:hover,
a.codelinenumber:visited,
a.codelinenumber:active {
    color: #880000;
}
a.codelinenumber {
    text-decoration: none;
	margin-right: 0.5em;
	float: left;
	color:#999999;
}
div.completecodeline {
    font-size: 12px;
	line-height: 1.4em;
	font-family: monospace;
	white-space: pre;
	display: block;
}

The float property is used to align the two links and the div so that it looks like a table.

Result

The result is quite positive. This implementation cuts the loading time by ~12sec when testing a 10,000 line cpp file in mozilla-central. The loading time currently on live is ~20sec and my implementation cuts it to ~8sec. This is around the same amount of time that Bonsai takes to load the same file. The browser doesn’t freeze and the initial screenful appears immediately just as jorendorff specified.

It is interesting to note that the size of the page on live (with the HUGE table) is 3.2MB while my solution cuts the file size down to 2.4MB, a 25% reduction.

, , ,

No Comments

v0.5 Release - Examining Two Patches Regarding the Hg Annotate Problem

In my previous blog post I had a look at the default and coal templates for hgweb in order to find a fix to the hg annotate problem. Neither of those templates presented a viable solution so the next step I decided to take was to have a look at a couple of patches that people have attached to the bug, which apparently reduced the loading time by a bit.

Patch by Smaug

Smaug is currently the person assigned to the bug and he put up a patch back in 2008 that got an r+ rating from ted. However, it doesn’t do exactly what jorendorff wants. The patch displays a loading message until the entire page is done loading and then shows the code. Instead, jorendorff wants the first screenful to appear almost right away. Thus, I decided to remove the loading message and then test the loading time of annotate. I was able to get a time of ~12sec to ~14sec on my machine when loading this file.

Obviously this is an improvement in loading time (currently the loading time is ~20sec). However, I want it to be even faster. One great thing about this patch is that now you can select code without selecting the line numbers. Another important change is that the huge table is now gone, replaced by div and pre tags. There are some things here that I can definitely use. I will be using div tags in my implementation as well but I don’t know if I will be doing it the same way as Smaug.

Patch by Mats Palmgren

The next patch I examined also gets rid of the table and uses a pre tag to display the code. I tested it on my machine and got a loading time of ~7sec to ~8sec. Now, this is a definite improvement over the current loading time. The increase in speed over the current implementation is very noticeable. However, the problem with this patch is that it doesn’t use valid HTML. I want my implementation to use valid HTML so I can’t really use the same type of implementation as this patch. I’ll have to come up with a more conventional approach.

Looking Ahead

I think by now I’ve researched all the resources that I could acquire. Now, I can get down to actually writing the patch. I’m pretty sure I know what to do, lets see how it turns out. Stay tuned!

, ,

No Comments

v0.5 Release - Examining How Other Templates Implement Hg Annotate

In order to complete the goals for my v0.5 release I examined how other templates implement hg annotate. I wanted to find out whether these other implementations had the ability to load 10,000 line cpp files quickly or not.

Default Template

Hgweb comes with a default template, which is quite ugly if you ask me but maybe it is efficient. I put together my local hgweb environment to use the default template and I was able to get a time of ~12secs. However, there was a major problem with this template. I noticed that after about 2000 lines the rest of the lines stopped showing up. The page kept loading new content but as I scrolled down the rest of the page was completely blank. None of the other 8000 or so lines of code were visible. This problem means that this template is of no use to me.

Coal Template

The next step was to try the coal template, which strangely doesn’t look very different from the default template. I configured my local hgweb environment to use the coal template and I got a time of ~14secs. This is not a significant improvement over Mozilla’s template which was clocking in at ~20secs but it is definitely better. Any reduction in loading time is a good thing. The problem is that gitweb_mozilla (the template that Mozilla uses) and the Coal template both use the same type of implementation. They both use one HUGE table to display the file, which obviously is not the correct method to employ (see below).

gitweb_mozilla

<div class="page_body">
  <table border="0">
    #annotate%annotateline#</table>
</div>

coal

<div class="overflow">
  <table class="bigtable" border="0">
    <tr>
      <th class="annotate">rev</th>
      <th class="lineno">line</th>
      <th class="line">source</th>
    </tr>
    {annotate%annotateline}
  </table>
</div>

Neither of these templates have been able to help me to solve my problem. Next I’ll be having a look at some of the patches that people put up on the bug page. Lets see if they improve annotate’s loading time or not.

, , ,

No Comments