Loose Screws

Recent Posts

January 23, 2025

How to solve "Array Manipulation" on HackerRank

The Array Manipulation challenge, as presented, is fairly simple: for a set of ranges and values, add each value to each element of an array that falls within its given range. The difficulty comes from the scale: if there are 10^6 ranges that each span 10^6 elements, the simplest solution requires 1,000,000,000,000 (that's one quadrillion) additions and loop iterations. And that number of operations just will not complete in the 2 second time limit for C++ submissions.

January 27, 2015

Better extension performance with Promises

Performance can be very hard to get right. Added performance that comes at the cost of code clarity can be difficult to sustain, and even large investments into performance may be wasted if aimed at a poor target. While choosing where to aim your optimization efforts may never be easy, we've recently chosen to focus on one high gain problem area, for both Firefox and its add-ons, and have begun to adopt a coding style which makes gains in this area very nearly free.

September 20, 2013

Add-on performance testing via power usage

We’ve struggled for a long time to programmatically measure the objective performance impact of add-ons on Firefox. While a perfect solution is still far off, we’ve recently started down an interesting new avenue: automatically measuring the impact of add-ons on the computer power consumption during test runs. This turns out to be a surprisingly useful proxy for performance overhead, since power consumption is directly affected by the amount of real work a CPU and GPU have to do, as well as total application runtime. Thanks to hardware donations from Intel, we’ve begun a preliminary set of automated test runs against a subset of the most popular Firefox add-ons. The results so far have been promising, with numbers generally well in line with our expectations.