Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Add Image Optimisations #54
Conversation
thelmstedt
added some commits
Oct 23, 2016
thelmstedt
commented
May 15, 2017
|
You should be able to just execute the main method in the benchmark to run, although I am using intellij (with the project loaded from gradle) to do so - YMMV. |
| @@ -239,8 +239,8 @@ private static ZipEntrySource openZipEntrySourceStream(ThresholdInputStream zis) | ||
| } | ||
| if (this.zipArchive == null) { | ||
| - return this.partList.values().toArray( |
onealj
May 15, 2017
Is partList.sortedValues() an expensive call? If so, the result should be saved in a temp variable so it doesn't have to be called twice.
Does this work?
return this.partList.sortedValues().toArray(
new PackagePart[this.partList.size()]);
thelmstedt
May 15, 2017
Whoops! Yeah that's actually how it's done further down the method. I'll make the change and ammend the pull request
| @@ -344,7 +344,7 @@ else if (contentType != null) { | ||
| } | ||
| } | ||
| - return partList.values().toArray(new ZipPackagePart[partList.size()]); |
thelmstedt
May 15, 2017
They actually are ZipPackageParts at that point, but the method returns PackagePart[] so no consumer can know about that. Seemed odd to force it to cast at that point, though it makes no real difference if you wanna keep it as it was.
| @@ -649,12 +649,11 @@ public PackagePart getPart(PackagePartName partName) { | ||
| */ |
onealj
May 15, 2017
I see that you started this pull request back in 2016. Have you rebased this to poi trunk (currently progressing towards 3.17 beta 1)?
thelmstedt
May 15, 2017
Yep, I've been running a version of this in production since Jan. I rebased before opening this pull request yesterday
onealj
commented
May 15, 2017
•
|
I like that benchmarking library. I have no reservations about making it a test dependency. There are plenty of other places we could use a benchmarking library. We have a few places of roll-your-own timed unit tests which will inevitably break on a sluggish build slave. Aside from our unit tests, integration tests, api checks, we could also trend execution memory and speed. This will be especially helpful as we look for an xmlbeans replacement. I've committed your changes, essentially unmodified, with a couple whitespace changes in SVN r1795252 https://svn.apache.org/viewvc?view=revision&revision=1795252 This is really good stuff. Be careful, though. We might just ask you to be a committer with this quality of pull requests. |
asfgit
closed this
in 5c62492
May 15, 2017
onealj
commented
May 16, 2017
|
These changes will be included in POI 3.17 beta 1. |
thelmstedt commentedMay 15, 2017
I need to be able to generate spreadsheets with 2000 images fast enough for a synchronous HTTP request.
3.16takes ~25 seconds for this usecase for me. These changes take it down to ~1 second. I've added a test for my case, and I don't get any more failures thantrunk. I don't think I've broken any invariants but it's definitely worth a 2nd look!The slowdown was caused by the cost of creating and sorting
PackagePartNames. I assume it's part of the OOXML spec so there's no avoiding the overhead. ButaddPicturehappened to make some redundant usage of these:PackagePartNames for eachTreeMap<PackagePartName, PackagePart>Instead we
.values()First commit adds a benchmark using http://openjdk.java.net/projects/code-tools/jmh/
Prior to my changes
addPicturegets:Afterwards we get 10x improvement in execution time, and 100x in memory:
Happy to back out the benchmark inclusion if you don't want to include another test dependency.