PixInsight 1.7 ? New PJSR Engine (SpiderMonkey 1.8.5)

Juan Conejero

PixInsight Staff
Staff member
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 script
1.6: 55.0 seconds
1.7: 39.7 seconds (28% faster)
Default script parameters. The resulting image is 11686x3872 px.

Spherize script
1.6: 4.21 seconds
1.7: 2.36 seconds (44% faster)
Rendition on a sphere of diameter = 1200 px.

PolarCoordinates script
1.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.
 
For those interested: The official standards document is here http://www.ecma-international.org/publications/standards/Ecma-262.htm .
Georg
 
John Resig has some good descriptions of the new ES5 features on his blog:

http://ejohn.org/blog/ecmascript-5-objects-and-properties/

as well as strict mode and JSON object serialization:

http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/

Also you may be interested in Mozilla's ES5 support (which is the same as PJSR's ES5 support):

https://developer.mozilla.org/En/JavaScript/ECMAScript_5_support_in_Mozilla
https://developer.mozilla.org/en/JavaScript/New_in_JavaScript/1.8.5
 
Extra speed is nice but more importantly, will this release have a debugger? As I recall we talked about that a year+ ago. That would be really huge.
 
will this release have a debugger? As I recall we talked about that a year+ ago. That would be really huge.

Not in this release, but I have it planned. Maybe during the 1.7 cycle. As you know I was thinking on migrating PJSR to SquirrelFish Extreme (Safari's JS engine). However, after the excellent development I've seen in SpiderMonkey during the last months I have decided to stick with Mozilla's engine. One of the reasons for taking this decision is the new Debug object:

https://wiki.mozilla.org/Debug_Object

which looks really promising IMO. Even before Debug is stable, I can add some (pretty basic, for now) debugging capabilities to PJSR thanks to ES5's greater introspection capabilities.
 
Another benchmark

Machine
  Intel Core 2 Quad Q9650 @ 3.00 GHz / 8 GB RAM

Operating System
  Windows 7 Ultimate 64bit

Test Image
  5000x5000 px / 32-bit floating point / Grayscale

PixInsight versions:
1.7 = 1.7.0.696 x64 (current publicly released version)
1.6 = 1.6.9.652 x64 (previously publicly released version)

MaskedStretch
1.6: 984.6 seconds
1.7: 474.7 seconds (~52% less time spent or 2.07x times faster!!!)
Script parameters are on screenshot.

That's a GREAT improvement in speed! Thanks a lot, Juan and the Team!
 

Attachments

  • MaskStr4W.gif
    MaskStr4W.gif
    29.7 KB · Views: 61
Back
Top