Skip to content

Commit

Permalink
Preventing resize overheat in SortVisibleSpans
Browse files Browse the repository at this point in the history
Every pass through is resizing the scratch buffers in SortVisibleSpans. This is resulting in a ~5% performance drag. Resize is deallocating and reallocating. Adding an if check to resize the buffers only when there is a risk of an overflow.

It’s possible this is a result of 78c0b48 which moved this storage over to std. I don’t know if the Cyan array implementation would have handled this.

I don’t see any reason this would create issues - there doesn’t seem to be code that relies on the size of the vectors. The vectors only need to be correctly sized to fit all the data required.
  • Loading branch information
colincornaby committed Dec 30, 2024
1 parent 76e31fe commit cc2e521
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1783,8 +1783,11 @@ void plDrawableSpans::SortVisibleSpans(const std::vector<int16_t>& visList, plPi

plProfile_IncCount(FacesSorted, totTris);

sortScratch.resize(totTris);
triList.resize(3 * totTris);
if( sortScratch.size() < totTris )
{
sortScratch.resize(totTris);
triList.resize(3 * totTris);
}

hsRadixSort::Elem* elem = sortScratch.data();

Expand Down

0 comments on commit cc2e521

Please sign in to comment.