Kaydet (Commit) 5c841052 authored tarafından Eike Rathke's avatar Eike Rathke

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
üst 7cf44445
...@@ -478,6 +478,9 @@ private: ...@@ -478,6 +478,9 @@ private:
std::unique_ptr<sc::IconSetBitmapMap> m_pIconSetBitmapMap; std::unique_ptr<sc::IconSetBitmapMap> m_pIconSetBitmapMap;
bool mbTrackFormulasPending : 1;
bool mbFinalTrackFormulas : 1;
public: public:
bool IsCellInChangeTrack(const ScAddress &cell,Color *pColCellBoder); bool IsCellInChangeTrack(const ScAddress &cell,Color *pColCellBoder);
void GetCellChangeTrackNote(const ScAddress &cell, OUString &strTrackText, bool &pbLeftEdge); void GetCellChangeTrackNote(const ScAddress &cell, OUString &strTrackText, bool &pbLeftEdge);
...@@ -2078,6 +2081,10 @@ public: ...@@ -2078,6 +2081,10 @@ public:
void AppendToFormulaTrack( ScFormulaCell* pCell ); void AppendToFormulaTrack( ScFormulaCell* pCell );
void RemoveFromFormulaTrack( ScFormulaCell* pCell ); void RemoveFromFormulaTrack( ScFormulaCell* pCell );
void TrackFormulas( sal_uInt32 nHintId = SC_HINT_DATACHANGED ); 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 IsInFormulaTree( ScFormulaCell* pCell ) const;
bool IsInFormulaTrack( ScFormulaCell* pCell ) const; bool IsInFormulaTrack( ScFormulaCell* pCell ) const;
HardRecalcState GetHardRecalcState() { return eHardRecalcState; } HardRecalcState GetHardRecalcState() { return eHardRecalcState; }
......
...@@ -1099,6 +1099,9 @@ void ScBroadcastAreaSlotMachine::LeaveBulkBroadcast() ...@@ -1099,6 +1099,9 @@ void ScBroadcastAreaSlotMachine::LeaveBulkBroadcast()
{ {
ScBroadcastAreasBulk().swap( aBulkBroadcastAreas); ScBroadcastAreasBulk().swap( aBulkBroadcastAreas);
BulkBroadcastGroupAreas(); BulkBroadcastGroupAreas();
// Trigger the "final" tracking.
if (pDoc->IsTrackFormulasPending())
pDoc->FinalTrackFormulas();
} }
} }
} }
......
...@@ -216,7 +216,9 @@ ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) : ...@@ -216,7 +216,9 @@ ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) :
mbStreamValidLocked( false ), mbStreamValidLocked( false ),
mbUserInteractionEnabled(true), mbUserInteractionEnabled(true),
mnNamedRangesLockCount(0), mnNamedRangesLockCount(0),
mbUseEmbedFonts(false) mbUseEmbedFonts(false),
mbTrackFormulasPending(false),
mbFinalTrackFormulas(false)
{ {
SetStorageGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT); SetStorageGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT);
......
...@@ -535,6 +535,21 @@ bool ScDocument::IsInFormulaTrack( ScFormulaCell* pCell ) const ...@@ -535,6 +535,21 @@ bool ScDocument::IsInFormulaTrack( ScFormulaCell* pCell ) const
return pCell->GetPreviousTrack() || pFormulaTrack == pCell; 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 first is broadcasted,
the ones that are created through this are appended to the Track by Notify. the ones that are created through this are appended to the Track by Notify.
...@@ -543,6 +558,11 @@ bool ScDocument::IsInFormulaTrack( ScFormulaCell* pCell ) const ...@@ -543,6 +558,11 @@ bool ScDocument::IsInFormulaTrack( ScFormulaCell* pCell ) const
*/ */
void ScDocument::TrackFormulas( sal_uInt32 nHintId ) void ScDocument::TrackFormulas( sal_uInt32 nHintId )
{ {
if (pBASM->IsInBulkBroadcast() && !IsFinalTrackFormulas() && nHintId == SC_HINT_DATACHANGED)
{
SetTrackFormulasPending();
return;
}
if ( pFormulaTrack ) if ( pFormulaTrack )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment