include/sfx2/docfile.hxx | 2 ++ include/sfx2/sfxsids.hrc | 3 ++- sfx2/sdi/sfx.sdi | 2 +- sfx2/source/appl/appuno.cxx | 1 + sfx2/source/doc/docfile.cxx | 21 +++++++++++++++------ sfx2/source/doc/objstor.cxx | 4 ++++ 6 files changed, 25 insertions(+), 8 deletions(-)
New commits: commit 643d257868247df19674fdf99aa8751d7413eaf3 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Jan 10 11:39:21 2018 +0100 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). (cherry picked from commit d03a754722980a4eaf14fce38d73ae23b604295b) Conflicts: sfx2/sdi/sfx.sdi Change-Id: I05e424a43ebfeea363f82b57af60f5aaa28696b4 Reviewed-on: https://gerrit.libreoffice.org/47978 Reviewed-by: Jan Holesovsky <ke...@collabora.com> Tested-by: Jan Holesovsky <ke...@collabora.com> diff --git a/include/sfx2/docfile.hxx b/include/sfx2/docfile.hxx index 07cfbe119c5b..7a4e34013195 100644 --- a/include/sfx2/docfile.hxx +++ b/include/sfx2/docfile.hxx @@ -168,6 +168,8 @@ public: void LockOrigFileOnDemand( bool bLoading, bool bNoUI ); void DisableUnlockWebDAV( bool bDisableUnlockWebDAV = true ); void UnlockFile( bool bReleaseLockStream ); + /// Lets Transfer_Impl() not fsync the output file. + void DisableFileSync(bool bDisableFileSync); css::uno::Reference< css::embed::XStorage > GetStorage( bool bCreateTempIfNo = true ); css::uno::Reference< css::embed::XStorage > GetOutputStorage(); diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc index d5620c01e9dd..ef179ffec2ca 100644 --- a/include/sfx2/sfxsids.hrc +++ b/include/sfx2/sfxsids.hrc @@ -253,8 +253,9 @@ #define SID_BLUETOOTH_SENDDOC (SID_SFX_START + 1726) #define SID_TEMPLATE_MANAGER (SID_SFX_START + 1727) #define SID_TOOLBAR_MODE (SID_SFX_START + 1728) +#define SID_NO_FILE_SYNC (SID_SFX_START + 1729) -// SID_SFX_free_START (SID_SFX_START + 1729) +// SID_SFX_free_START (SID_SFX_START + 1730) // SID_SFX_free_END (SID_SFX_START + 3999) #define SID_OPEN_NEW_VIEW (SID_SFX_START + 520) diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index f1c0ef53c703..b69776927254 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -3690,7 +3690,7 @@ SfxBoolItem SaveAll SID_SAVEDOCS SfxBoolItem 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 cdda5c948177..8527c2b3e0d2 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -105,6 +105,7 @@ SfxFormalArgument 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 = sizeof(aFormalArgs) / sizeof (SfxFormalArgument); diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 76ff7a30ec32..100241c7c8b5 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -189,6 +189,7 @@ public: bool m_bRemote:1; bool m_bInputStreamIsReadOnly:1; bool m_bInCheckIn:1; + bool m_bDisableFileSync = false; OUString m_aName; OUString m_aLogicName; @@ -1967,13 +1968,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 @@ -2729,6 +2733,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 ed67e58d5a11..d373917c3158 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -2783,6 +2783,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 ) ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits