Last week in WebKit: Millions of lines!

 Uncategorized  Comments Off
May 222013
 

Another week in WebKit land. Let’s make this quick, since I’m already late with the blog!

New behaviors:

Infrastructure changes:

Random cool stuff:

Honorable mention:

The WebKitten of the Week is Darin Adler, who’s continuing his awesome crusade to clean up the DOM Clipboard implementationThis sentence is pure filler so I get more words to link.

Last week in WebKit: simplifying everything

 Uncategorized  Comments Off
May 142013
 

Last week, everyone became crazy about refactoring. Some have taken “spring cleaning” very literally and many patches landed to make WebKit simpler and cleaner.

A nice change ties to the way Objective-C objects are adopted by RetainPtr. Previously, there were 3 ways to adopt a pointer:

RetainPtr<id> foo = adoptNS([...]);
RetainPtr<id> bar(AdoptNS, [...]);
RetainPtr<id> baz;
baz.adoptNS([...]);

Darin Adler and Anders Carlsson wrote a few patches to unify all the code behind the adoptNS([...]) syntax. Some bugs were also discovered and fixed on the way.

Another great refactoring by Darin and Anders was switching from manual management of memory to smart pointers when possible. In particular, they hunted the use of deleteAllValues() on various data structure and updated their storage to use WTF’s OwnPtr. The new code is easier to reason about, and it becomes hard to accidentally leak memory on those structures.

There were also some nice cleaning of headers to rationalize where everything is defined in WTF.

New behaviors:

As usual, there were a lot of bug fixes. Some visible changes:

Talking about canvas, I spent a little time improving fillStyle and strokeStyle on Canvas2D’s context. A pattern I have seen is code recreating a CanvasPattern or CanvasGradient with every frame. For example:

function draw() {
    var gradient = context.createRadialGradient(...);
    gradient.addColorStop(...);
    context.strokeStyle = gradient;
    context.lineTo(...)
}

When the Gradient/Pattern is constant from frame to frame, it’s much better to initialize the objects at the beginning and reuse them with every frame. Unfortunately, many tutorials fall into the trap of trashing the objects.

Engine engineering

The WebKitten of the week is Anders Carlsson for making this blog difficult with over 50 patches. Half of them refactoring and cleaning the code, the other half adding features to WebKit2.

Things to look forward to:

Last week in WebKit: Out of the Shadows

 Uncategorized  Comments Off
May 082013
 

Last week, the annual WebKit Contributors’ meeting was held in San Jose, and WebKittens from all over the world came to talk about all things WebKit. Transcripts from some of the sessions are available on the wiki. Because of the meeting, there was a bit less hacking than usual since people were traveling and socializing.

New behaviors:

Infrastructure changes:

Engine hackery:

Testing hackery:

Announcing SunSpider 1.0

 Uncategorized  Comments Off
May 012013
 

The popular SunSpider JavaScript benchmark suite was originally released by the WebKit team over five years ago, in December 2007. It was engineered to be a balance of real JavaScript code from the web, and to serve as a blueprint for the sorts of language-level operations that the WebKit JavaScript engine should, but was as yet unable to, optimize. And optimize we did: intriguingly, the original version of the benchmark reported an execution time of 9206.2ms in Safari 3 on a 2.33 GHz machine. Running the SunSpider 0.9 benchmark on a modern browser like Safari 6 with a recent machine, such as my 2.2GHz i7 MacBook Pro, can easily result in a score around 250ms—this represents over a 30-fold improvement!

Yet despite such dramatic performance improvements and the introduction of other suites like Kraken and Octane, SunSpider continues to be a useful benchmark. SunSpider focuses on a broad range of JavaScript operations, from Date, String, and Regexp manipulation to a wide variety of numerical, array-oriented, object-oriented, and functional idioms. Compared to other suites, SunSpider places greater emphasis on features that make JavaScript uniquely difficult to optimize, such as ‘eval’ and ‘for/in’. Most importantly, SunSpider is a simple and practical test of not just how quickly JavaScript code can execute if it has been running for a while, but also, how quickly the engine can warm up for very short-running code. Most websites don’t have JavaScript event handlers that run for seconds at a time; thus, SunSpider’s focus on short-running tests has direct relevance to the web.

Today we’d like to announce SunSpider 1.0, an update of the suite that fixes a number of bugs and aims to further increase test accuracy and repeatability. This update comprises fixes to test validation, better interaction with power management, and a backlog of minor fixes to the harness and tests.

Test Validation

SunSpider was originally written at a time when JavaScript engines used relatively straight-forward interpretation or template compilation strategies. Consequently it didn’t make sense for the tests to defend against optimizing compiler tricks that could lead to the entirety of the test being folded away as dead code. It also didn’t make much sense to validate the tests’ output—if your execution strategy is just interpretation, then you can validate your engine’s correctness using other approaches (like test262), and leave the benchmark to just measure execution time.

But the JavaScript runtimes of today employ increasingly sophisticated execution tiers. For example, WebKit’s JavaScript engine has three execution engines: an interpreter for start-up code, a template just-in-time compiler (JIT) for polymorphic code, and an optimizing JIT for long-running structured code. Optimizing compilers for JavaScript are increasingly capable of eliminating dead code: code whose results are known to be never used. But even more importantly, as the engines reach ever-higher levels of complexity, it makes sense to make our benchmarks perform some validation of correctness. Benchmarks are uniquely capable of stressing the optimizing JIT in a way that conformance tests cannot. This observation comes from our own experience: as we added validation to our benchmarks, we were able to catch bugs sooner.

We address both problems by adding validation checks to 23 out of the 26 SunSpider tests. The validation checks are intended to incur minimal overhead to the running-time of the tests: <2% overhead was our goal. The tests not covered by validation are ones where results depend on timezone or random number generation; on those tests we expect different users and implementations to get different results. We also do not perform validation on the exact results of certain math functions like Math.sin(), since ECMAScript 5 permits these functions to return implementation-dependent results.

These validation checks serve two purposes: they force the JavaScript engine to execute the test in full, and they provide a quick way of checking that the engine executed the test correctly.

The changes to include test validation and prevent dead code elimination are covered by WebKit bugs 38446, 63863, 114852, and 114895.

Power Management

Short-running tests of the sort used in SunSpider require special care from the test harness. The SunSpider 1.0 release further improves the repeatability of test execution times by eliminating the delay that previous versions used between test executions, thus reducing the chances of interference from the operating system’s power management logic.

The original SunSpider 0.9 test harness employed a 500ms delay between tests. The intent was to give the browser a chance to complete any asynchronous activities before doing another round of measurement. But performance improved, and the power management facilities in modern operating systems became more sophisticated. Running a test that took on average 10ms with a 500ms delay between test executions meant that the machine could enter a lower clock-rate, power-saving state for each test execution. If power management did kick in, the machine would run slower, and the SunSpider score would be penalized. Whether power management kicked in or not depended on a variety of factors outside the harness’s control. Paradoxically, this would lead to slower or noisier machines exhibiting higher performance. A slower machine would be active for a higher fraction of the test time slice thereby reducing the likelihood of interference from power management. A noisier machine—for example a machine also busy doing other work while SunSpider testing was in progress—would also have a chance of getting a better result because the noisiness would also inhibit power management.

The SunSpider 0.9.1 update attempted to address this problem by reducing the test delay to 10ms instead of 500ms. But as SunSpider performance has further improved due to a combination of hardware improvements and JavaScript engine enhancements, we are once again seeing power management cause unpredictable SunSpider slow-downs. For example, testing on a 2.7GHz MacBook Pro may occasionally lead to worse results than a 2.2GHz MacBook Pro, not because the hardware is any worse or because the browser is any different but because the faster machine appears to be active for a smaller fraction of time. Worse, the faster machine does not consistently run slower; we have observed bimodal execution times that ping-pong between 130ms and 150ms depending on the state of the machine.

Having bimodal results on fast hardware runs counter to our goal of making SunSpider a reliable and repeatable test. We considered various solutions to this problem. We could have made SunSpider tests run longer, but rejected this approach since one of SunSpider’s unique strengths is its short-running nature; also, other JavaScript benchmarks already do a good job of providing test coverage for long-running programs. We also considered requiring users to disable power management prior to running SunSpider; this could have worked but would have made the tests more difficult to use. Ultimately we chose to remove the 10ms test delay entirely. The original intent of the test delay was to improve the repeatability and reliability of SunSpider rather than inhibit it. As we played with the delay, we found that eliminating the delay entirely eliminated the bimodal results on fast hardware, and never significantly hurt test repeatability on any hardware platform we tested.

SunSpider 1.0 eliminates the delay between test executions. In addition to reducing interference from power management facilities, it also has two other useful side-effects:

  1. The SunSpider test suite now runs up to twice as fast. Typical SunSpider tests require less than 10ms to run on fast machines, so the 10ms delay between test executions meant that most of the running time of SunSpider was spent idling. Removing this delay means that the tests finish faster, by spending less time waiting in between individual tests.
  2. SunSpider now gives the browser less opportunity to hide asynchronous activities from the test harness. Our goal is to measure as much of a JavaScript engine’s overheads as possible. A 10ms delay between <10ms test runs meant that a browser that aggressively postponed garbage collection (GC) activity until idle time would never have any of its GC overheads measured by the benchmark. Postponing GC activity until idle time is a well-documented technique for improving performance, but we don’t view it as a goal of SunSpider to specifically reward that aspect of a browser’s memory management strategy. GC performance is important, and we believe that SunSpider should err on the side of measuring it rather than ignoring it.

The change to improve test repeatability when power management is in effect is covered by bug 114458.

Minor Tweaks in the Harness

SunSpider 1.0 also includes a handful of additional fixes and features in the command-line and in-browser test harnesses:

  • bug 47045: The harness doesn’t actually close() its test documents.
  • bug 60937: Avoid using an undeclared variable named ‘name’, which is a DOM API.
  • bug 71799: Extend SunSpider driver to be able to run Kraken.
  • bug 80783: Add –instruments option to SunSpider to profile with Instruments.

Give it a try!

We invite you to try out our new SunSpider 1.0 benchmark suite, report your findings, and provide feedback if you encounter unexpected issues. It is still possible, though not recommended, to run previous versions of the harness from the all versions page.

Last week in WebKit: staying above 50 mph

 Uncategorized  Comments Off
Apr 292013
 

This year’s WebKit Contributors Meeting is almost there: it starts next Thursday. The Contributors meeting is a great opportunity for contributors to discuss the future of WebKit.

If you are attending, don’t forget to prepare demos if you have anything cool to show, and update the wiki with suggestions for the Talks/Hackathons.

New exposed behaviors

Joseph Pecoraro added column numbers to the error messages displayed in the Inspector console.

Allan Sandfeld Jensen added support for mouseenter and mouseleave events. These are enabled by default and available for testing in the nightly builds.

Engine engineering

There were a lot of performance optimizations this week. I cannot really list half of them so here are some cool random ones:

  • Ryosuke Niwa, after banging his head on the wall for a couple of days, improved the performance of rendering a new selection by 20%.
  • Antti Koivisto and Andreas Kling made a few changes to avoid recomputing the style when possible.
  • Roman Zhuykov made a nice little DFG optimization. A little context: in JavaScript, double values have a negative zero: -0.0, while negative integer are represented with two’s complement do not have a negative zero. Roman changed the code generation to avoid checking for negative zero when certain conditions are met.
  • Oliver Hunt added support for JavaScript Math.imul, and made it fast with baseline JIT and DFG implementations.

Some other stuff happening:

The WebKitten of the week is Christophe Dumez for his great work on the binding generator and WebKit’s WebIDLs! It looks like we may have a new maintainer for the code generators.

Things to look forward to:

Jisc seeks a Wikimedian Ambassador

 Uncategorized  Comments Off
Apr 242013
 

For some time now it has been evident that the academic community are becoming more involved in the improvement of information on Wikipedia and see it as a means of disseminating open scholarly information. For example take a look at this oii project.

Jisc has,over the last decade, worked closely with many institutions to develop rich content for teaching, learning and research but also to develop digital infrastructure, promote standards and improve the use of technology in learning. We are now delighted to offer the opportunity for academics to become involved in improving information relating to these activities.  Please find Jisc’s ITT for the Wikimedian Ambassador residency here.

Share and Enjoy

FacebookTwitterDeliciousLinkedInStumbleUponAdd to favoritesEmailRSS

Last week in WebKit: All cowhands on deck!

 Uncategorized  Comments Off
Apr 232013
 

It’s been a smooth week in WebKit land. Improvements to build times and executable sizes are still coming in, as the codebase continues to recover from the departure of the Chromium port.

New features:

Infrastructure changes:

Random cool stuff:

Last week in WebKit: a new hope

 Uncategorized  Comments Off
Apr 152013
 

A lot of great changes happened this week. There was the first stable release of WebKitGTK+ 2, which is the GTK+ port of WebKit2. A lot of cleaning has been going on and WebKit is getting smaller and building faster. The bot infrastructure has also been moved over from old servers to their new home independent from chromium.

New behaviors

Some new features this week:

Engine engineering

All of the infrastructure that was handled by chrome is now moved to WebKit. The sheriffbot is now known as webkitbot and is smarter (and wittier).

The commit queue is moved to http://webkit-queues.appspot.com. The test-results server is here: http://webkit-test-results.appspot.com.

JavaScript strings got faster thanks to a DFG implementation of String comparison, and of String.fromCharCode. Rendering also got faster with smarter tiling heuristics during loading and window resizing.

A lot of proactive work was being done around security, two notable changes are the addition of bound checking on the Vector class, and a beginning of process sandboxing on Linux for WebKit2 with seccomp filters.

The main effort this week was still around cleaning the code left over from chromium. Some people are also taking the opportunity to refactor header inclusion to reduce build time.

The WebKitten of the week is Ryosuke Niwa for a fantastic job on migrating all the infrastructure and on cleaning WebKit.

Some cool things to look forward to: