diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2016-03-16 15:14:13 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2016-03-22 08:56:08 +0000 |
commit | 7e2ea27e5d56f5cf767a6718a0f5edc28e24af14 (patch) | |
tree | 63673e8a3f21ef7438fdb46edfa627e4d1aa7050 /package/source/zippackage/ZipPackageStream.cxx | |
parent | 0f0cea28c75a6565c7803b54536d4a8720ead160 (diff) |
tdf#93553 limit parallelism at zip save time to useful amount
At ODT export time writing and zipping comtained data packages is nicely
parallelized, but not limited to an upper bounds of threads to use.
Together with memory consumption this makes ressource usage and runtime
behaviour bad to crashing (mostly on 32bit).
I have now limited the processing dependent on the number of available
cores to get a good processing/ressource ratio. The result uses much less
memory, is faster and runs on 32bit systems.
Change-Id: I8bd516a9a0cefd644f5d7001214bc717f29770ab
Reviewed-on: https://gerrit.libreoffice.org/23305
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'package/source/zippackage/ZipPackageStream.cxx')
-rw-r--r-- | package/source/zippackage/ZipPackageStream.cxx | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx index 2fbcfdba19ff..a183cf651796 100644 --- a/package/source/zippackage/ZipPackageStream.cxx +++ b/package/source/zippackage/ZipPackageStream.cxx @@ -54,6 +54,7 @@ #include <rtl/random.h> #include <PackageConstants.hxx> +#include <thread> using namespace com::sun::star::packages::zip::ZipConstants; using namespace com::sun::star::packages::zip; @@ -478,6 +479,7 @@ private: deflateZipEntry(mpEntry, mxInStream); mxInStream.clear(); mpEntry->closeBufferFile(); + mpEntry->setFinished(); } catch (const uno::Exception&) { @@ -824,6 +826,13 @@ bool ZipPackageStream::saveChild( if (bParallelDeflate) { + // tdf#93553 limit to a useful amount of threads. Taking number of available + // cores and allow 4-times the amount for having the queue well filled. The + // 2nd pparameter is the time to wait beweeen cleanups in 10th of a second. + // Both values may be added to the configuration settings if needed. + static sal_Int32 nAllowedThreads(std::max(std::thread::hardware_concurrency(), 1U) * 4); + rZipOut.reduceScheduledThreadsToGivenNumberOrLess(nAllowedThreads, 1); + // Start a new thread deflating this zip entry ZipOutputEntry *pZipEntry = new ZipOutputEntry( m_xContext, *pTempEntry, this, bToBeEncrypted); |