SVG benchmarks

For rasterizing SVG images we've used librsvg for some time. Another contender which we didn't choose originally is Batik. There are several respects in which librsvg is unsatisfactory and Batik might be preferable.

librsvg: In favour: fast; totally free/libre. Against: Lots of GNOME-ish dependencies, which makes tracking updates difficult; We have to maintain a security patch to disable the loading of external URL resources, since librsvg maintainers weren't interested in it; Lots of rendering bugs (but it's improved over time); Unclear fonts/text rendering situation.

Batik: In favour: more mature; higher quality rendering; built-in security mode. Against: slow!; doesn't (or at least didn't) run on free/libre Java (GCJ etc).

Benchmark
Brion did a quick test of SVG rendering (19 Dec 2006), with 50 images pulled off Commons. Test run on a MacBook, 2 GHz Intel Core 2 Duo, in Ubuntu running under Parallels (using one virtual processor). rsvg is 2.16.0 as apt-get'd via Ubuntu; batik is 1.6, running on Sun's J2SE 6 runtime.


 * rsvg: 18.07 seconds; 361.46ms per image
 * batik: 108.44 seconds; 2168.84ms per image

Batik is probably slowed down by having to start up the VM and JIT on every call. It likely can be sped up by using a daemon process and handing off render requests to that.

Batik also refused to render one file that rsvg did render.

ivar notes that to avoid JDK startup time you can use nailgun.

Additional notes

 * Batik command-line renderer appears to scale image height to be proportional with the given width. This could produce width/height inconsistencies between specified heights from MW and results.
 * I'm pretty sure Batik has a mode for increased safety (rejecting external links), which we have to maintain as a patch hack for librsvg. Not having to maintain a patch is attractive.
 * We frequently get requests about font support. It'd be nice to know how to answer such questions.
 * rsvg's resource usage can be limited with ulimit etc easily; what about a batik daemon? How to stop giiaaannttttt files from eating up RAM without taking down the server?
 * You'd have to look at jvm args... -- chris

Further testing
David Gerard ran a test of ImageMagick 6.2.4, Inkscape 0.45.1, Batik 1.7.0 (on Sun Java 1.6.0_03-b05) and rsvg 2.18.2 on 58 Commons images, including some in the megabytes. Those which gave an error from the renderers were left out. Test box was a Dell Latitude D610, Pentium M 1.6 GHz, 512MB memory, running Kubuntu 7.10. All test applications except Batik were Ubuntu repository versions.

Test files were: 12communesWilayaConstantine.svg                               EspecesMammiferesMenacees_fr.svg 18_ABC_DUI.svg                                                Flag_of_Cyprus_(bordered).svg 1-D_kinematics.svg                                            Flag_of_Ten_Boer.svg 2006_Brazilian_Election_2nd_round.svg                         Glasbutton_Tipp.svg 2006_Brazilian_Election_Senators.svg                          HH_object_diagram.svg 200pF_capacitance.svg                                         Ironless_electric_motor.svg Accidentals-piano_keyboard.svg                                Japanese_Road_sign_(Children).svg Adjustable_wrench.svg                                         Japanese_Road_sign_(Falling_rocks).svg African_language_families.svg                                 Map_of_USA,_NFL.svg A_large_blank_world_map_with_oceans_marked_in_blue.svg        Map_of_US_sodomy_laws.svg Alaska_compared_to_Lower_48.svg                               MARTA_Rail_Map.svg AMD_A64_Opteron_arch.svg                                      NucleicAcid.svg Ankerreactie.svg                                              Nuvola_apps_kalzium.svg Arms_Arbuthnot_of_Edinburgh_(entire).svg                      Nuvola_apps_package_graphics.svg Arms_Viscount_of_Arbuthnott_(entire).svg                      Pfeil_links_oben.svg At-will_employment_-_covenant-of-good-faith-and-fair-dealing_exceptions.svg Pictgram_bicycle_man.svg Aztreonam_structure.svg                                       Primitive.svg Ballvalve.svg                                                 Q_space.svg BBC_broadcasting_expenditure_2005-2006.svg                    Replace_this_image_PL.svg BlankMap-USA-states-Canada-provinces.svg                      Sierpiński_curve_order_5.svg Blason_54.svg                                                 Squaring_the_square.svg Blason_ville_fr_Ablis_(Yvelines).svg                          Status_9.svg Brain_Surface_Gyri.SVG                                        SVG_filter_feTurbulence.svg CD-R.svg                                                      Symbol_LED.svg Cherenkov2.svg                                                USA_Counties.svg Cometorbit.svg                                                Violet_box.svg Cross_montessa.svg                                            Wikipedia's_W.svg Cscr-former.svg                                               X_Cubed.svg Ensign_of_the_Royal_Australian_Air_Force.svg

David was browsing, playing music, etc. while running the tests, so ran them several times.

[test results to go here]

Worrying:
 * Batik's JVM crapped itself several times for no apparent reason.
 * Inkscape thrashed the disk. (Single physical disk in laptop.)