sc/inc/interpretercontext.hxx | 2 +- sc/source/core/tool/interpr1.cxx | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-)
New commits: commit a49afabb0cf1eac8f1214bfada0d7c9bc662878e Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Tue May 10 21:30:31 2022 +0200 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Wed May 11 11:52:04 2022 +0200 reduce size of *IFS conditions array (tdf#144777) The array is used to count the number of matching conditions e.g. in COUNTIFS, which can be only up to nQueryCount, which is sal_uInt8. So there's no need to count it as sal_uInt32, and doing so may cause 4MiB array per thread for full-column references, which causes easily causes 60% of time spent just clearing and checking the complete array. Change-Id: Id4bebf90619f7f2a721edb9cd31e6a11469579aa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134138 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/sc/inc/interpretercontext.hxx b/sc/inc/interpretercontext.hxx index 07e20f3a887e..9f424b1a4f42 100644 --- a/sc/inc/interpretercontext.hxx +++ b/sc/inc/interpretercontext.hxx @@ -61,7 +61,7 @@ struct ScInterpreterContext std::unique_ptr<ScSortedRangeCacheMap> mxScSortedRangeCache; // cache for unsorted lookups // Allocation cache for "aConditions" array in ScInterpreter::IterateParameterIfs() // This is populated/used only when formula-group threading is enabled. - std::vector<sal_uInt32> maConditions; + std::vector<sal_uInt8> maConditions; ScInterpreter* pInterpreter; ScInterpreterContext(const ScDocument& rDoc, SvNumberFormatter* pFormatter); diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index afd9079de498..ce05f771bd6d 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -5827,7 +5827,7 @@ void ScInterpreter::IterateParametersIfs( double(*ResultFunc)( const sc::ParamIf sal_uInt8 nParamCount = GetByte(); sal_uInt8 nQueryCount = nParamCount / 2; - std::vector<sal_uInt32>& vConditions = mrContext.maConditions; + std::vector<sal_uInt8>& vConditions = mrContext.maConditions; // vConditions is cached, although it is clear'ed after every cell is interpreted, // if the SUMIFS/COUNTIFS are part of a matrix formula, then that is not enough because // with a single InterpretTail() call it results in evaluation of all the cells in the @@ -5886,7 +5886,7 @@ void ScInterpreter::IterateParametersIfs( double(*ResultFunc)( const sc::ParamIf SCCOL nDimensionCols = 0; SCROW nDimensionRows = 0; const SCSIZE nRefArrayRows = GetRefListArrayMaxSize( nParamCount); - std::vector<std::vector<sal_uInt32>> vRefArrayConditions; + std::vector<std::vector<sal_uInt8>> vRefArrayConditions; while (nParamCount > 1 && nGlobalError == FormulaError::NONE) { @@ -6016,7 +6016,7 @@ void ScInterpreter::IterateParametersIfs( double(*ResultFunc)( const sc::ParamIf } // Reset condition results. std::for_each( vConditions.begin(), vConditions.end(), - [](sal_uInt32 & r){ r = 0.0; } ); + [](sal_uInt8 & r){ r = 0.0; } ); } } nRefArrayPos = nRefInList; @@ -6192,7 +6192,7 @@ void ScInterpreter::IterateParametersIfs( double(*ResultFunc)( const sc::ParamIf if (nRefArrayPos != std::numeric_limits<size_t>::max()) { // Apply condition result to reference list array result position. - std::vector<sal_uInt32>& rVec = vRefArrayConditions[nRefArrayPos]; + std::vector<sal_uInt8>& rVec = vRefArrayConditions[nRefArrayPos]; if (rVec.empty()) rVec = vConditions; else @@ -6207,9 +6207,9 @@ void ScInterpreter::IterateParametersIfs( double(*ResultFunc)( const sc::ParamIf // When leaving an svRefList this has to be emptied not set to // 0.0 because it's checked when entering an svRefList. if (nRefInList == 0) - std::vector<sal_uInt32>().swap( vConditions); + std::vector<sal_uInt8>().swap( vConditions); else - std::for_each( vConditions.begin(), vConditions.end(), [](sal_uInt32 & r){ r = 0.0; } ); + std::for_each( vConditions.begin(), vConditions.end(), [](sal_uInt8 & r){ r = 0; } ); } } nParamCount -= 2; @@ -6392,7 +6392,7 @@ void ScInterpreter::IterateParametersIfs( double(*ResultFunc)( const sc::ParamIf return; } - std::vector<sal_uInt32>::const_iterator itRes = vConditions.begin(), itResEnd = vConditions.end(); + std::vector<sal_uInt8>::const_iterator itRes = vConditions.begin(), itResEnd = vConditions.end(); std::vector<double>::const_iterator itMain = aMainValues.begin(); for (; itRes != itResEnd; ++itRes, ++itMain) { @@ -6427,7 +6427,7 @@ void ScInterpreter::IterateParametersIfs( double(*ResultFunc)( const sc::ParamIf if (nRefArrayMainPos < vRefArrayConditions.size()) vConditions = vRefArrayConditions[nRefArrayMainPos]; - std::vector<sal_uInt32>::const_iterator itRes = vConditions.begin(); + std::vector<sal_uInt8>::const_iterator itRes = vConditions.begin(); for (SCCOL nCol = 0; nCol < nDimensionCols; ++nCol) { for (SCROW nRow = 0; nRow < nDimensionRows; ++nRow, ++itRes)