summaryrefslogtreecommitdiff
path: root/package/inc
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2016-03-16 15:14:13 +0100
committerArmin Le Grand <Armin.Le.Grand@cib.de>2016-03-22 08:56:08 +0000
commit7e2ea27e5d56f5cf767a6718a0f5edc28e24af14 (patch)
tree63673e8a3f21ef7438fdb46edfa627e4d1aa7050 /package/inc
parent0f0cea28c75a6565c7803b54536d4a8720ead160 (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/inc')
-rw-r--r--package/inc/ZipOutputEntry.hxx10
-rw-r--r--package/inc/ZipOutputStream.hxx10
2 files changed, 19 insertions, 1 deletions
diff --git a/package/inc/ZipOutputEntry.hxx b/package/inc/ZipOutputEntry.hxx
index 450cc39b9bc8..cac0c2ffa584 100644
--- a/package/inc/ZipOutputEntry.hxx
+++ b/package/inc/ZipOutputEntry.hxx
@@ -28,6 +28,7 @@
#include <package/Deflater.hxx>
#include <CRC32.hxx>
+#include <atomic>
struct ZipEntry;
class ZipPackageBuffer;
@@ -35,6 +36,9 @@ class ZipPackageStream;
class ZipOutputEntry
{
+ // allow only DeflateThread to change m_bFinished using setFinished()
+ friend class DeflateThread;
+
css::uno::Sequence< sal_Int8 > m_aDeflateBuffer;
ZipUtils::Deflater m_aDeflater;
css::uno::Reference< css::uno::XComponentContext > m_xContext;
@@ -48,8 +52,9 @@ class ZipOutputEntry
CRC32 m_aCRC;
ZipEntry *m_pCurrentEntry;
sal_Int16 m_nDigested;
- bool m_bEncryptCurrentEntry;
ZipPackageStream* m_pCurrentStream;
+ bool m_bEncryptCurrentEntry;
+ std::atomic<bool> m_bFinished;
public:
ZipOutputEntry(
@@ -78,7 +83,10 @@ public:
void closeEntry();
void write(const css::uno::Sequence< sal_Int8 >& rBuffer);
+ bool isFinished() const { return m_bFinished; }
+
private:
+ void setFinished() { m_bFinished = true; }
void doDeflate();
};
diff --git a/package/inc/ZipOutputStream.hxx b/package/inc/ZipOutputStream.hxx
index 16740095bd92..f995469b29e6 100644
--- a/package/inc/ZipOutputStream.hxx
+++ b/package/inc/ZipOutputStream.hxx
@@ -69,6 +69,16 @@ private:
throw(css::io::IOException, css::uno::RuntimeException);
void writeEXT( const ZipEntry &rEntry )
throw(css::io::IOException, css::uno::RuntimeException);
+
+ // ScheduledThread handling helpers
+ void consumeScheduledThreadEntry(ZipOutputEntry* pCandidate);
+ void consumeFinishedScheduledThreadEntries();
+ void consumeAllScheduledThreadEntries();
+
+public:
+ void reduceScheduledThreadsToGivenNumberOrLess(
+ sal_Int32 nThreads,
+ sal_Int32 nWaitTimeInTenthSeconds);
};
#endif