{"id":924,"date":"2010-04-07T11:28:27","date_gmt":"2010-04-07T15:28:27","guid":{"rendered":"http:\/\/2d823b65bb.nxcli.io\/?p=924"},"modified":"2010-04-07T11:28:27","modified_gmt":"2010-04-07T15:28:27","slug":"odf-performance-tip-1","status":"publish","type":"post","link":"https:\/\/www.robweir.com\/blog\/2010\/04\/odf-performance-tip-1.html","title":{"rendered":"ODF Performance Tip #1: Don&#8217;t re-compress images"},"content":{"rendered":"<p><a href=\"http:\/\/odftoolkit.org\/projects\/odfdom\/pages\/Home\">ODFDOM<\/a> is an open source (Apache 2.0) Java library for reading, writing and modifying ODF documents.\u00a0 It runs standalone, not requiring OpenOffice.org or any other editor to be installed.\u00a0 It operates directly on the ODF document itself.<\/p>\n<p>One of the things we&#8217;re focusing on in the next release of (the 0.9 release) is optimizing the performance, getting ODFDOM to read and write ODF documents as fast as possible, and with as low a memory footprint as possible.\u00a0 The aim is to make it optimal for concurrent use, say in a Java servlet.<\/p>\n<p>Some of the the things we&#8217;re finding as we profile ODFDOM are worth sharing, since they are not specific to this library.\u00a0 They are tips and techniques that are applicable more broadly, potentially to all applications that work with ODF documents.\u00a0 I&#8217;ll do a series of posts on these ideas.\u00a0 Hopefully you will find them useful and maybe even can share your tricks as well.<\/p>\n<p>The first thing I&#8217;ll point out concerns documents with many image resources, such as large presentation files with a lot of graphics.\u00a0 We found that writing these documents was rather slow.\u00a0 The problem was in how the images were stored in the ZIP archive.\u00a0 As you may know, ZIP allows a file to be compressed (most commonly using the <a href=\"http:\/\/en.wikipedia.org\/wiki\/DEFLATE\">DEFLATE<\/a> algorithm).\u00a0 Most ZIP libraries will, by default, compress every file you add to the archive.\u00a0 However, for many common media types, like PNG and JPG images, the data has already been compressed, at the level of the image encoding.\u00a0 So if you have your ZIP library try to compress the images a second time, you will typically waste time with very little incremental savings in storage.<\/p>\n<p>Most ZIP libraries have an alternative way to store files in their original, uncompressed form, a method called STORE.\u00a0 What we found in ODFDOM was that if we store images rather than compress them, the time needed to save our large presentation was reduced by 20%, while the size of the archive increased only 3%.\u00a0 So this was a good trade-off.<\/p>\n<p>I think this technique would be applicable to other libraries and editors.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ODFDOM is an open source (Apache 2.0) Java library for reading, writing and modifying ODF documents.\u00a0 It runs standalone, not requiring OpenOffice.org or any other editor to be installed.\u00a0 It operates directly on the ODF document itself. One of the things we&#8217;re focusing on in the next release of (the 0.9 release) is optimizing the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[9,21],"tags":[],"class_list":{"0":"post-924","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-odf","7":"category-performance","8":"entry"},"_links":{"self":[{"href":"https:\/\/www.robweir.com\/blog\/wp-json\/wp\/v2\/posts\/924","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.robweir.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.robweir.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.robweir.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.robweir.com\/blog\/wp-json\/wp\/v2\/comments?post=924"}],"version-history":[{"count":4,"href":"https:\/\/www.robweir.com\/blog\/wp-json\/wp\/v2\/posts\/924\/revisions"}],"predecessor-version":[{"id":928,"href":"https:\/\/www.robweir.com\/blog\/wp-json\/wp\/v2\/posts\/924\/revisions\/928"}],"wp:attachment":[{"href":"https:\/\/www.robweir.com\/blog\/wp-json\/wp\/v2\/media?parent=924"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.robweir.com\/blog\/wp-json\/wp\/v2\/categories?post=924"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.robweir.com\/blog\/wp-json\/wp\/v2\/tags?post=924"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}