Hi all,
The new version 1.7.0 of PixInsight includes a new JavaScript engine: SpiderMonkey version 1.8.5, the latest version of
Mozilla's JavaScript engine. This is the same engine used in Firefox 4.
SpiderMonkey 1.8.5 is a huge step forward because it includes two JIT (Just-In-Time) compilers: a trace-based JIT (also known as
TraceMonkey) and a method JIT (also known as
JaegerMonkey). The JIT compilers translate JavaScript code into machine code dynamically, while the scripts execute.
This has been a relatively complex and time-consuming task because I've had to rewrite most of PJSR code, but it is now 100% operational and fully tested. As expected, it has been well worth the effort: the performance improvement is spectacular.
Here are some benchmarks:
Machine
Intel Core i7 990 X @ 3.47 GHz / 24 GB RAM
Operating System
Fedora 14 Linux x86_64 / Kernel 2.6.35.12-90 / GNOME 2.32.0
Test Image
1522x1262 px / 32-bit floating point / RGB color
PixInsight versions:
1.7 = 1.7.0.684 (development version)
1.6 = 1.6.9.652 (current publicly released version)
3DPlot script1.6: 55.0 seconds
1.7: 39.7 seconds (28% faster)
Default script parameters. The resulting image is 11686x3872 px.
Spherize script1.6: 4.21 seconds
1.7: 2.36 seconds (44% faster)
Rendition on a sphere of diameter = 1200 px.
PolarCoordinates script1.6: 3.93 seconds
1.7: 1.28 seconds (67% faster)
Scripts whose execution times are dominated by native PJSR routines have bottlenecks that make JIT compiler optimizations comparatively less relevant. This is the case of the 3DPlot script, which is strongly dominated by the polygon drawing PJSR routine (Graphics.drawPolygon()), hence the relatively 'small' improvement (28%).
On the other hand, those scripts consisting mostly of 'pure' JavaScript code see the best improvements, as happens with Spherize (44%) and PolarCoordinates (67%). These scripts basically carry out their entire tasks in JavaScript, then call ultra-fast PJSR routines to write image pixels.
Besides optimizations and performance improvements, the new PJSR in PixInsight 1.7 fully implements the ECMAScript 262-5 standard (with the exception of the Math object, which PJSR redefines to provide a much more powerful and faster math support). This includes ES5's strict mode, getters, setters, JSON, etc. The new strict mode is optional --which means that all existing scripts will continue working without problems-- but we encourage all developers to write strict mode compliant code, as well as to port existing scripts when necessary. All PJSR headers, the development scripts and all scripts automatically generated by the PI Core application are now strict mode compliant. The most 'dramatic' impact of strict mode on existing PJSR scripts is the fact that the 'with () {}' statement is now forbidden. I'll comment more on the repercussions of this change in a new post.