<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Rob Sayre&#039;s Mozilla Blog &#187; JS</title>
	<atom:link href="http://blog.mozilla.com/rob-sayre/category/js/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mozilla.com/rob-sayre</link>
	<description>This Must Be the Place (Naive Melody)</description>
	<lastBuildDate>Wed, 14 Oct 2009 22:47:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Keeping An Eye On Things</title>
		<link>http://blog.mozilla.com/rob-sayre/2007/10/16/keeping-an-eye-on-things/</link>
		<comments>http://blog.mozilla.com/rob-sayre/2007/10/16/keeping-an-eye-on-things/#comments</comments>
		<pubDate>Wed, 17 Oct 2007 05:19:36 +0000</pubDate>
		<dc:creator>rsayre</dc:creator>
				<category><![CDATA[JS]]></category>
		<category><![CDATA[webapps]]></category>

		<guid isPermaLink="false">http://blog.mozilla.com/rob-sayre/2007/10/16/keeping-an-eye-on-things/</guid>
		<description><![CDATA[Tests
The best time to catch bugs is before they make it into a nightly build, so we&#8217;ve been working hard on infrastructure to help us detect defects as early as possible. Our most-used tool, tinderbox, has been augmented with much-improved regression testing functionality.

We now execute extensive tests after every checkin, usually more than 50 thousand [...]]]></description>
			<content:encoded><![CDATA[<p><b>Tests</b></p>
<p>The best time to catch bugs is before they make it into a nightly build, so we&#8217;ve been working hard on infrastructure to help us detect defects as early as possible. Our most-used tool, <a href="http://tinderbox.mozilla.org/showbuilds.cgi?tree=Firefox">tinderbox</a>, has been augmented with much-improved regression testing functionality.</p>
<p><img src="http://people.mozilla.com/~sayrer/2007/10/17/tinderbox.png"></p>
<p>We now execute extensive tests after every checkin, usually more than 50 thousand or so. We&#8217;re being very inclusive about it as well, so we&#8217;ve added tests from JavaScript libraries like <a href="http://www.prototypejs.org/">prototype.js</a>. This is really handy when we&#8217;re working on touchy functions like setTimeout&mdash;the <a href="http://script.aculo.us/">script.aculo.us</a> tests caught a bug in one of my patches <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=330128">today</a>. We&#8217;ve always had the most complete <a href="http://lxr.mozilla.org/mozilla/source/js/tests/">JavaScript test suite</a>, and we&#8217;re getting closer to that ideal in the rest of the browser. Problems with bidi diacritics? <a href="http://mxr.mozilla.org/mozilla/source/layout/reftests/bidi/bidi-004.html">Never again</a>.</p>
<p>Testing can cover more than correctness, though. We now have more performance coverage than ever. We can see that our switch to <a href="http://en.wikipedia.org/wiki/Quartz_(graphics_layer)">Quartz</a> on Mac OS X has improved our SVG performance quite a bit. We can see areas where our JS implementation is <a href="http://ejohn.org/apps/speed/">pretty darn fast</a>, and we can also see areas that we need to improve.</p>
<p><img src="http://people.mozilla.com/~sayrer/2007/10/17/talos.png"></p>
<p>One of the best parts of our new performance testing infrastructure is the <a href="http://quality.mozilla.org/en/projects/automation/talos">Talos</a> framework. We use it for a variety of synthetic benchmarks, and we also test against reference copies of popular websites. It turns out that Asian pages that look sort of like yahoo.com comprise a large proportion of those, at least accoding to the big ratings agencies. We&#8217;ve also been able to pinpoint systemic performance issues in our infrastructure with these tools. Some of them have short term fixes, some long term, but it&#8217;s only going to get better.</p>
<p><b>Leaks</b></p>
<p>One of the trickiest problems in browser engineering is integrating memory management schemes across languages. Usually, there is a host language, such as C++, C, or Objective-C, and JavaScript. In many circumstances, the host language is <a href="http://en.wikipedia.org/wiki/Reference_counting">reference counted</a>, while the JavaScript implementation is <a href="http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)">garbage collected</a> (GC).</p>
<p>For Firefox 4, we&#8217;re <a href="http://benjamin.smedbergs.us/blog/2007-10-16/using-dehydra-to-detect-problematic-code/">moving towards GC</a> for all but the most performance-sensitive pieces of code, using high performance code donated to the Mozilla project by Adobe/Macromedia. For Firefox 3, we&#8217;ll use a <a href="http://citeseer.ist.psu.edu/383143.html">cycle collector</a> to improve our memory management in comparison to Firefox 2.</p>
<p>We&#8217;re also increasing our level of automated defect detection in this area. <a href="http://www.squarefree.com/">Jesse Ruderman</a> has been developing ever more advanced <a href="http://en.wikipedia.org/wiki/Fuzz_testing">fuzzers</a> for leak and security testing. His stuff is getting really scary. We&#8217;re also parallelizing leak testing by running <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=394517">leak check scripts</a> on <a href="http://www.amazon.com/gp/browse.html?node=201590011">Amazon EC2</a>. EC2 lets us run many parallel leak checking machines against a randomly generated selection of websites. This is great, because we find problems in pages that testers and engineers probably wouldn&#8217;t look at. For instance, <a href="http://www.golfballoutlet.com/">www.golfballoutlet.com</a> no longer leaks. <img src='http://blog.mozilla.com/rob-sayre/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><b>Whodunnit</b></p>
<p>The best part about this project is that so many people have helped. To be sure, there are contributors that dwarf the rest of us, but I think everyone who&#8217;s deeply involved in the project knows who they are. I&#8217;m more interested in the long tail of bugs assigned to people I&#8217;ve never met. Just today, Malcom Parsons fixed a <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=244135">table damage area bug</a>. I don&#8217;t know Malcom, and I only have the foggiest idea of what a table damage area is (though if I need to know more, I can jump on <a href="http://irc.mozilla.org/">irc</a> and find out).</p>
<p><b>Epilogue</b></p>
<p>Lastly, I&#8217;m positive you&#8217;re interested in what I&#8217;ve been up to (yeah, yeah). Mostly I&#8217;ve been putting a lot of time into busting leaks and other performance issues. But, I do have a pet bug that&#8217;s a performance issue for a few pieces of our code, and probably lots of websites: <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=387522">native JSON support</a>. This will help with the security issues that have faced JSON parsing in JS, and speed up object serialization considerably.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mozilla.com/rob-sayre/2007/10/16/keeping-an-eye-on-things/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Using JS 1.7 Features to Simplify Mozilla Application Code</title>
		<link>http://blog.mozilla.com/rob-sayre/2007/01/20/using-js-1.7-features-to-simplify-mozilla-application-code/</link>
		<comments>http://blog.mozilla.com/rob-sayre/2007/01/20/using-js-1.7-features-to-simplify-mozilla-application-code/#comments</comments>
		<pubDate>Sat, 20 Jan 2007 16:30:05 +0000</pubDate>
		<dc:creator>rsayre</dc:creator>
				<category><![CDATA[JS]]></category>

		<guid isPermaLink="false">http://blog.mozilla.com/rob-sayre/2007/01/20/using-js-1.7-features-to-simplify-mozilla-application-code/</guid>
		<description><![CDATA[JS 1.7 landed in time for Firefox 2. It&#8217;s not practical to use its new features on the Web yet, but the Mozilla project can use them to eliminate some of the uglier aspects of our applications&#8217; own JS code. As a case study, I&#8217;ll use the nsISimpleEnumerator object returned from an nsILocalFile that&#8217;s a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://developer.mozilla.org/en/docs/New_in_JavaScript_1.7">JS 1.7</a> landed in time for Firefox 2. It&#8217;s not practical to use its new features on the Web yet, but the Mozilla project can use them to eliminate some of the uglier aspects of our applications&#8217; own JS code. As a case study, I&#8217;ll use the <a href="http://developer.mozilla.org/en/docs/nsISimpleEnumerator">nsISimpleEnumerator</a> object returned from an <a href="http://developer.mozilla.org/en/docs/nsILocalFile">nsILocalFile</a> that&#8217;s a directory. The enumerator interface encourages some pretty <a href="http://lxr.mozilla.org/seamonkey/search?string=hasMoreElements">ugly code</a>, with while loops containing conditional blocks, break and continue statements, counters, etc. That sort of code is obviously hard to read, and it&#8217;s also hard to test.</p>
<p>We can simplify this type of thing with <a href="http://developer.mozilla.org/en/docs/New_in_JavaScript_1.7#Generators">generators</a> and <a href="http://developer.mozilla.org/en/docs/New_in_JavaScript_1.7#Array_comprehensions">array comprehensions</a>.</p>
<p>Start <a href="http://developer.mozilla.org/en/docs/xpcshell">XPCShell</a> with a <code>-v 170</code> argument to turn on JS 1.7.</p>
<pre>
~/firefox/mozilla/fb-debug/dist/bin&gt; ./xpcshell -v 170
…
js&gt; const Ci = Components.interfaces;
js&gt; const Cc = Components.classes;
js&gt; /** Create a generator function to wrap the enumerator interface **/
js&gt; function dirIter(dir) {
      var enum = dir.directoryEntries;
      while (enum.hasMoreElements()) {
        var file = enum.getNext();
        yield file.QueryInterface(Ci.nsILocalFile);
      }
    }
js&gt; /** Create an nsILocalFile and set the path to my home directory **/
js&gt; var d = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
js&gt; d.initWithPath("/Users/sayrer/");
js&gt; /** Use our generator function and an array comprehension to get a list of the paths **/
js&gt; var paths = [f.path for (f in dirIter(d))];
js&gt; print(paths.join("\n"));
/Users/sayrer/.bash-profile
/Users/sayrer/.bash_history
/Users/sayrer/.emacs
…
/Users/sayrer/bin
/Users/sayrer/bonecho
/Users/sayrer/camino
…
/Users/sayrer/webapp
/Users/sayrer/XULRunner
js&gt; /** Use a conditional to show only directories **/
js&gt; var dirPaths = [f.path for (f in dirIter(d)) if (f.isDirectory())];
js&gt; print(dirPaths.join("\n"));
/Users/sayrer/bin
/Users/sayrer/bonecho
/Users/sayrer/camino
…
/Users/sayrer/webapp
/Users/sayrer/XULRunner
js&gt;</pre>
<p>We should try to keep a list of this stuff, and move the ideas into <a href="http://wiki.mozilla.org/FUEL">FUEL</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mozilla.com/rob-sayre/2007/01/20/using-js-1.7-features-to-simplify-mozilla-application-code/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
