diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-01-10 11:39:21 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-01-10 14:35:47 +0100 |
commit | d03a754722980a4eaf14fce38d73ae23b604295b (patch) | |
tree | 9f5c12ecff1420bbed6f57968e2c3e5ed6e92f7b /sfx2/source/doc | |
parent | e1026e267b4b1b0b0bd645c6bc212d6fa71544f8 (diff) |
sfx2 store: add API to allow avoiding the fsync of the output file
The use-case is when the consumer of the output file will read it right
after SfxBaseModel::storeToURL() returns, in which case an expensive
fsync is pointless.
Times for 100 hello world inputs: 8516 -> 2785 ms is spent in ODT-load + HTML
export + close (33% of original).
Change-Id: I05e424a43ebfeea363f82b57af60f5aaa28696b4
Reviewed-on: https://gerrit.libreoffice.org/47695
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sfx2/source/doc')
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 21 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 4 |
2 files changed, 19 insertions, 6 deletions
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 59dd5307877c..92f0665110af 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -191,6 +191,7 @@ public: bool m_bRemote:1; bool m_bInputStreamIsReadOnly:1; bool m_bInCheckIn:1; + bool m_bDisableFileSync = false; OUString m_aName; OUString m_aLogicName; @@ -1972,13 +1973,16 @@ void SfxMedium::Transfer_Impl() { TransactedTransferForFS_Impl( aSource, aDest, xComEnv ); - // Hideous - no clean way to do this, so we re-open the file just to fsync it - osl::File aFile( aDestURL ); - if ( aFile.open( osl_File_OpenFlag_Write ) == osl::FileBase::E_None ) + if (!pImpl->m_bDisableFileSync) { - aFile.sync(); - SAL_INFO( "sfx.doc", "fsync'd saved file '" << aDestURL << "'" ); - aFile.close(); + // Hideous - no clean way to do this, so we re-open the file just to fsync it + osl::File aFile( aDestURL ); + if ( aFile.open( osl_File_OpenFlag_Write ) == osl::FileBase::E_None ) + { + aFile.sync(); + SAL_INFO( "sfx.doc", "fsync'd saved file '" << aDestURL << "'" ); + aFile.close(); + } } } else @@ -2734,6 +2738,11 @@ void SfxMedium::DisableUnlockWebDAV( bool bDisableUnlockWebDAV ) pImpl->m_bDisableUnlockWebDAV = bDisableUnlockWebDAV; } +void SfxMedium::DisableFileSync(bool bDisableFileSync) +{ + pImpl->m_bDisableFileSync = bDisableFileSync; +} + void SfxMedium::UnlockFile( bool bReleaseLockStream ) { #if !HAVE_FEATURE_MULTIUSER_ENVIRONMENT diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index e50fdfcffc82..b470d8f60177 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -2739,6 +2739,10 @@ bool SfxObjectShell::PreDoSaveAs_Impl(const OUString& rFileName, const OUString& // create a medium for the target URL SfxMedium *pNewFile = new SfxMedium( rFileName, StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE | StreamMode::TRUNC, nullptr, pMergedParams ); + const SfxBoolItem* pNoFileSync = pMergedParams->GetItem<SfxBoolItem>(SID_NO_FILE_SYNC, false); + if (pNoFileSync && pNoFileSync->GetValue()) + pNewFile->DisableFileSync(true); + // set filter; if no filter is given, take the default filter of the factory if ( !aFilterName.isEmpty() ) pNewFile->SetFilter( GetFactory().GetFilterContainer()->GetFilter4FilterName( aFilterName ) ); |