Skip to content

storage::clear or storage::pop_all optimization #1311

@jeanlemotan

Description

@jeanlemotan

Hi,

First of all, thanks for this awesome lib. We're building an engine on top of it and it's going great.
There is one issue that is bugging me while profiling: clearing a storage with tens of thousands of components is very slow. Like 1.37ms for 60K entities, which is comparable to computing and adding those components in the first place.
The component in question is a POD with no destructor:

struct VisibilityStats
{
	float cameraDistanceSq = 0;
	float screenRatioSq = 0;
	Lod lod = k_bestLod;
};

I've seen that the pop_all function which seems to do all the work goes item by item to destroy the components, but it also swaps and pops, which seems unnecessary? After all, we're clearing, so that seems like something that can be skipped.
I'm still familiarizing myself with the code though, so maybe I missed something.

Metadata

Metadata

Assignees

Labels

enhancementaccepted requests, sooner or later I'll do it

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions