Pregunta

Impressed by the performance of Dart I put together a quite simple web-app to render the Mandelbrot set in Dart (using HTML5 canvas). This is by all means not meant as a realistic performance test. The page renders the Mandelbrot set in a 800x600 canvas with a max-depth of 10.000. The app can be seen here: http://goo.gl/DLuQp

What puzzles me: running in Dartium the image renders in about 8.5 seconds (which is impressive). The same page in Firefox takes >15 seconds. No surprise there.

But running the same page in Chrome (version 27.0.1453.93), which does not run Dart but the JS version as well completes in 6.7 seconds, faster than Dart?

Why is that so?

UPDATE: I added a "Run" button to re-render the canvas (to verify warm-up behaviour). Also I added a JS-only version (same code of course) to check JS in Dartium. In short: the figures and my question remains as is. Warm-up seems to have no effect. The JS-version is faster in Dartium than the Dart-version.

UPDATE after closed question: Just for the record: in this specific case moving the code into parallel workers/isolates not only resulted in a significant performance boost, also Dart now clearly leaves the JS-version behind in the dust by factor 10.

¿Fue útil?

Solución 2

It's a known issue with the canvas bindings and APIs. See http://dartbug.com/10344

Otros consejos

There could be several reasons. Out of the top of my head:

  • Dart VM misses out on some optimizations. V8 is much older than the Dart-VM and some optimizations just didn't make it into Dart yet.
  • You are not running a warmup run. The Dart-VM currently does not do OSR (on-stack replacement). When a function is invoked it will finish in the same "mode" in which it was started. That is, if an important function is started in non-optimized mode, but contains a loop that is really important (and runs for a long time) then the Dart VM will not replace it with the optimized version. An easy workaround is to execute the function (possibly with a smaller value) first so that the function gets optimized. Eventually OSR will make it into the Dart VM.
  • Make sure you don't run in checked mode. The Dart-VM can be much faster in unchecked mode.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top