diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-01-10 11:39:21 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-07-16 16:55:53 +0200 |
commit | 27d0abe7eca73722980228520f3a3ccdf3f844a3 (patch) | |
tree | 430b2775a949d17fb444a89ca830f946a442bc25 /sfx2 | |
parent | 64804142904cbb2df38138b0c53b4a5790104814 (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>
(cherry picked from commit d03a754722980a4eaf14fce38d73ae23b604295b)
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/sdi/sfx.sdi | 2 | ||||
-rw-r--r-- | sfx2/source/appl/appuno.cxx | 1 | ||||
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 21 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 4 |
4 files changed, 21 insertions, 7 deletions
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 659e3763bfd1..de632285788f 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -3538,7 +3538,7 @@ SfxVoidItem SaveAll SID_SAVEDOCS SfxStringItem SaveAs SID_SAVEASDOC -(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxStringItem Password SID_PASSWORD,SfxBoolItem PasswordInteraction SID_PASSWORDINTERACTION,SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxStringItem VersionComment SID_DOCINFO_COMMENTS,SfxStringItem VersionAuthor SID_DOCINFO_AUTHOR,SfxBoolItem Overwrite SID_OVERWRITE,SfxBoolItem Unpacked SID_UNPACK,SfxBoolItem SaveTo SID_SAVETO) +(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxStringItem Password SID_PASSWORD,SfxBoolItem PasswordInteraction SID_PASSWORDINTERACTION,SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxStringItem VersionComment SID_DOCINFO_COMMENTS,SfxStringItem VersionAuthor SID_DOCINFO_AUTHOR,SfxBoolItem Overwrite SID_OVERWRITE,SfxBoolItem Unpacked SID_UNPACK,SfxBoolItem SaveTo SID_SAVETO,SfxBoolItem NoFileSync SID_NO_FILE_SYNC) [ AutoUpdate = FALSE, FastCall = FALSE, diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index a5bc1ea0b959..a0bf23d483f6 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -105,6 +105,7 @@ SfxFormalArgument const aFormalArgs[] = { { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "Unpacked", SID_UNPACK }, { reinterpret_cast<SfxType*>(&aSfxInt16Item_Impl), "Version", SID_VERSION }, { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "SaveACopy", SID_SAVEACOPYITEM }, + { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "NoFileSync", SID_NO_FILE_SYNC }, }; static sal_uInt16 nMediaArgsCount = SAL_N_ELEMENTS(aFormalArgs); diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 273d201e94d0..c6e4a55e2091 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -194,6 +194,7 @@ public: bool m_bRemote:1; bool m_bInputStreamIsReadOnly:1; bool m_bInCheckIn:1; + bool m_bDisableFileSync = false; OUString m_aName; OUString m_aLogicName; @@ -2024,13 +2025,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 @@ -2786,6 +2790,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 de065085c217..9b48caac795c 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -2751,6 +2751,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 ) ); |