From 39bd42108d75cd68496a67ee274f9afd18ae8ac3 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Thu, 5 May 2016 18:56:03 +0200 Subject: [PATCH] improve perf. of removal of mult. slides --- ...-improve-perf.-of-VCL-event-dispatch.patch | 72 +++++++++++++++++++ ...-page-once-when-removing-mult.-pages.patch | 54 ++++++++++++++ libreoffice.spec | 2 + 3 files changed, 128 insertions(+) create mode 100644 0001-improve-perf.-of-VCL-event-dispatch.patch create mode 100644 0001-only-set-cur.-page-once-when-removing-mult.-pages.patch diff --git a/0001-improve-perf.-of-VCL-event-dispatch.patch b/0001-improve-perf.-of-VCL-event-dispatch.patch new file mode 100644 index 0000000..222e3b1 --- /dev/null +++ b/0001-improve-perf.-of-VCL-event-dispatch.patch @@ -0,0 +1,72 @@ +From 9ff1d7f8140de1224bb37fba0cb266a58f37e66d Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Thu, 5 May 2016 15:53:06 +0200 +Subject: [PATCH] improve perf. of VCL event dispatch + +Anectodal evidence: for removal of 32 slides from 64 slide presentation, +time spent in Window::CallEventListeners has been cut down from 70% to +19% of the total time. + +Change-Id: Ic8fbb44fa935f068e1b18235592dec0d7e71aec7 +--- + vcl/inc/window.h | 2 ++ + vcl/source/window/event.cxx | 13 ++++++++++++- + vcl/source/window/window.cxx | 1 + + 3 files changed, 15 insertions(+), 1 deletion(-) + +diff --git a/vcl/inc/window.h b/vcl/inc/window.h +index e06a6b1..302e9d0 100644 +--- a/vcl/inc/window.h ++++ b/vcl/inc/window.h +@@ -201,6 +201,8 @@ public: + VclPtr mpLastFocusWindow; + VclPtr mpDlgCtrlDownWindow; + std::vector> maEventListeners; ++ int mnEventListenersIteratingCount; ++ std::set> maEventListenersDeleted; + std::vector> maChildEventListeners; + int mnChildEventListenersIteratingCount; + std::set> maChildEventListenersDeleted; +diff --git a/vcl/source/window/event.cxx b/vcl/source/window/event.cxx +index cb39104..68e822b 100644 +--- a/vcl/source/window/event.cxx ++++ b/vcl/source/window/event.cxx +@@ -216,11 +216,22 @@ void Window::CallEventListeners( sal_uLong nEvent, void* pData ) + { + // Copy the list, because this can be destroyed when calling a Link... + std::vector> aCopy( mpWindowImpl->maEventListeners ); ++ // we use an iterating counter/flag and a set of deleted Link's to avoid O(n^2) behaviour ++ mpWindowImpl->mnEventListenersIteratingCount++; ++ auto& rWindowImpl = *mpWindowImpl; ++ comphelper::ScopeGuard aGuard( ++ [&rWindowImpl]() ++ { ++ rWindowImpl.mnEventListenersIteratingCount--; ++ if (rWindowImpl.mnEventListenersIteratingCount == 0) ++ rWindowImpl.maEventListenersDeleted.clear(); ++ } ++ ); + for ( Link& rLink : aCopy ) + { + if (xWindow->IsDisposed()) break; + // check this hasn't been removed in some re-enterancy scenario fdo#47368 +- if( std::find(mpWindowImpl->maEventListeners.begin(), mpWindowImpl->maEventListeners.end(), rLink) != mpWindowImpl->maEventListeners.end() ) ++ if( rWindowImpl.maEventListenersDeleted.find(rLink) == rWindowImpl.maEventListenersDeleted.end() ) + rLink.Call( aEvent ); + } + } +diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx +index f245c47..d1c1ffe 100644 +--- a/vcl/source/window/window.cxx ++++ b/vcl/source/window/window.cxx +@@ -615,6 +615,7 @@ WindowImpl::WindowImpl( WindowType nType ) + mpNextOverlap = nullptr; // next overlap window of frame + mpLastFocusWindow = nullptr; // window for focus restore + mpDlgCtrlDownWindow = nullptr; // window for dialog control ++ mnEventListenersIteratingCount = 0; + mnChildEventListenersIteratingCount = 0; + mpUserData = nullptr; // user data + mpCursor = nullptr; // cursor +-- +2.7.4 + diff --git a/0001-only-set-cur.-page-once-when-removing-mult.-pages.patch b/0001-only-set-cur.-page-once-when-removing-mult.-pages.patch new file mode 100644 index 0000000..0883667 --- /dev/null +++ b/0001-only-set-cur.-page-once-when-removing-mult.-pages.patch @@ -0,0 +1,54 @@ +From fd99dc83659b8c9e4dff9c55ed43c936f9a5b7fd Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Thu, 5 May 2016 17:47:03 +0200 +Subject: [PATCH] only set cur. page once when removing mult. pages + +Change-Id: Id9da135a91d9591eed04fb25d2891169c45ecaaf +--- + .../ui/slidesorter/controller/SlsSelectionManager.cxx | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx +index a954aed..c861fbf 100644 +--- a/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx ++++ b/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx +@@ -36,6 +36,9 @@ + #include "view/SlideSorterView.hxx" + #include "view/SlsLayouter.hxx" + #include "drawdoc.hxx" ++#include "drawview.hxx" ++#include "DrawViewShell.hxx" ++#include "ViewShellBase.hxx" + #include "Window.hxx" + #include + #include +@@ -108,6 +111,13 @@ void SelectionManager::DeleteSelectedPages (const bool bSelectFollowingPage) + else + --nNewCurrentSlide; + ++ const auto pViewShell = mrSlideSorter.GetViewShell(); ++ const auto pDrawViewShell = pViewShell ? std::dynamic_pointer_cast(pViewShell->GetViewShellBase().GetMainViewShell()) : nullptr; ++ const auto pDrawView = pDrawViewShell ? dynamic_cast(pDrawViewShell->GetDrawView()) : nullptr; ++ ++ if (pDrawView) ++ pDrawView->BlockPageOrderChangedHint(true); ++ + // The actual deletion of the selected pages is done in one of two + // helper functions. They are specialized for normal respectively for + // master pages. +@@ -120,6 +130,12 @@ void SelectionManager::DeleteSelectedPages (const bool bSelectFollowingPage) + + mrController.HandleModelChange(); + aLock.Release(); ++ if (pDrawView) ++ { ++ assert(pDrawViewShell); ++ pDrawView->BlockPageOrderChangedHint(false); ++ pDrawViewShell->ResetActualPage(); ++ } + + // Show focus and move it to next valid location. + if (bIsFocusShowing) +-- +2.7.4 + diff --git a/libreoffice.spec b/libreoffice.spec index 84b19c8..1cdfc48 100644 --- a/libreoffice.spec +++ b/libreoffice.spec @@ -236,6 +236,8 @@ Patch6: 0001-add-X-TryExec-entries-to-desktop-files.patch Patch7: 0001-pass-original-CFLAGS.patch Patch8: 0001-rbhz-1326602-avoid-exp.-bg-bitmaps-from-deleted-slid.patch Patch9: 0001-tdf-99353-take-the-footgun-away-from-FilterCache.patch +Patch10: 0001-improve-perf.-of-VCL-event-dispatch.patch +Patch11: 0001-only-set-cur.-page-once-when-removing-mult.-pages.patch %if 0%{?rhel} # not upstreamed