[Libreoffice-commits] core.git: sc/inc sc/source
Eike Rathke
erack at redhat.com
Tue Sep 27 18:51:14 UTC 2016
sc/inc/document.hxx | 7 +++++++
sc/source/core/data/bcaslot.cxx | 3 +++
sc/source/core/data/documen2.cxx | 4 +++-
sc/source/core/data/documen7.cxx | 20 ++++++++++++++++++++
4 files changed, 33 insertions(+), 1 deletion(-)
New commits:
commit 5c841052abdf082b4cbe06784cfdd76f11fafef2
Author: Eike Rathke <erack at redhat.com>
Date: Tue Sep 27 19:40:31 2016 +0200
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
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 79e5b83..757b878 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 73b5ee6..2051f2c 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 534a788..fa481a3 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 1a61323..d64b286 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 )
{
More information about the Libreoffice-commits
mailing list