diff options
author | Eike Rathke <erack@redhat.com> | 2016-09-27 19:40:31 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-09-27 20:48:45 +0200 |
commit | 5c841052abdf082b4cbe06784cfdd76f11fafef2 (patch) | |
tree | e3ee926c9d7e23035acc8234eef3aed16cca1eb9 | |
parent | 7cf444454c0c27e2f6d764164ea880b87163f45a (diff) |
sc-perf: avoid repeated TrackFormulas() during bulk broadcast, tdf#87101 rel.
Multiple callers involved. Most significantly ScDocument::Broadcast()
calls ScDocument::TrackFormulas() individually. Track/collect pending
formula cells at the end of the bulk broadcast instead, which gives an
instructions read speedup by factor 6 for the broadcast, and an overall
speedup in the scenario for inserting the rows by factor ~2 wall clock
time.
ScDocument::InsertRows()
Before, Ir Incl: 282,227,033,656
After, Ir Incl: 66,307,994,805
With cycle detection:
ScDocument::TrackFormulas()
Before:
Ir Incl Ir Self
66,981,644,959 11,913,444,899
After:
Ir Incl Ir Self
10,819,556,073 1,973,232,494
Change-Id: I85fe8b03ecb52cffaa6fa14354b3cc3467ecc111
-rw-r--r-- | sc/inc/document.hxx | 7 | ||||
-rw-r--r-- | sc/source/core/data/bcaslot.cxx | 3 | ||||
-rw-r--r-- | sc/source/core/data/documen2.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/documen7.cxx | 20 |
4 files changed, 33 insertions, 1 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 79e5b8392883..757b87884088 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -478,6 +478,9 @@ private: std::unique_ptr<sc::IconSetBitmapMap> m_pIconSetBitmapMap; + bool mbTrackFormulasPending : 1; + bool mbFinalTrackFormulas : 1; + public: bool IsCellInChangeTrack(const ScAddress &cell,Color *pColCellBoder); void GetCellChangeTrackNote(const ScAddress &cell, OUString &strTrackText, bool &pbLeftEdge); @@ -2078,6 +2081,10 @@ public: void AppendToFormulaTrack( ScFormulaCell* pCell ); void RemoveFromFormulaTrack( ScFormulaCell* pCell ); void TrackFormulas( sal_uInt32 nHintId = SC_HINT_DATACHANGED ); + void SetTrackFormulasPending() { mbTrackFormulasPending = true; } + bool IsTrackFormulasPending() const { return mbTrackFormulasPending; } + void FinalTrackFormulas(); + bool IsFinalTrackFormulas() const { return mbFinalTrackFormulas; } bool IsInFormulaTree( ScFormulaCell* pCell ) const; bool IsInFormulaTrack( ScFormulaCell* pCell ) const; HardRecalcState GetHardRecalcState() { return eHardRecalcState; } diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx index 73b5ee6fbc9a..2051f2cf4ee3 100644 --- a/sc/source/core/data/bcaslot.cxx +++ b/sc/source/core/data/bcaslot.cxx @@ -1099,6 +1099,9 @@ void ScBroadcastAreaSlotMachine::LeaveBulkBroadcast() { ScBroadcastAreasBulk().swap( aBulkBroadcastAreas); BulkBroadcastGroupAreas(); + // Trigger the "final" tracking. + if (pDoc->IsTrackFormulasPending()) + pDoc->FinalTrackFormulas(); } } } diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index 534a78849e38..fa481a3421cc 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -216,7 +216,9 @@ ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) : mbStreamValidLocked( false ), mbUserInteractionEnabled(true), mnNamedRangesLockCount(0), - mbUseEmbedFonts(false) + mbUseEmbedFonts(false), + mbTrackFormulasPending(false), + mbFinalTrackFormulas(false) { SetStorageGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT); diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx index 1a61323fa1f5..d64b286d4638 100644 --- a/sc/source/core/data/documen7.cxx +++ b/sc/source/core/data/documen7.cxx @@ -535,6 +535,21 @@ bool ScDocument::IsInFormulaTrack( ScFormulaCell* pCell ) const return pCell->GetPreviousTrack() || pFormulaTrack == pCell; } +void ScDocument::FinalTrackFormulas() +{ + mbTrackFormulasPending = false; + mbFinalTrackFormulas = true; + { + ScBulkBroadcast aBulk( GetBASM()); + // Collect all pending formula cells in bulk. + TrackFormulas(); + } + // A final round not in bulk to track all remaining formula cells and their + // dependents that were collected during ScBulkBroadcast dtor. + TrackFormulas(); + mbFinalTrackFormulas = false; +} + /* The first is broadcasted, the ones that are created through this are appended to the Track by Notify. @@ -543,6 +558,11 @@ bool ScDocument::IsInFormulaTrack( ScFormulaCell* pCell ) const */ void ScDocument::TrackFormulas( sal_uInt32 nHintId ) { + if (pBASM->IsInBulkBroadcast() && !IsFinalTrackFormulas() && nHintId == SC_HINT_DATACHANGED) + { + SetTrackFormulasPending(); + return; + } if ( pFormulaTrack ) { |