Skip to content

Possible performance gain in injector #58

@sigvaldm

Description

@sigvaldm

I found another place with lots of pointer dereferencing (ExteriorFacet), which can be optimized if it is found necessary to improve the injector performance.

Mesh has an array (or vector) of fine-grained ExteriorFacet objects. That's a typical Array-of-Objects data structure. Although Array-of-Objects is perfectly in agreement with the OO-philosophy, it is often more efficient to flip the arrangment to an Object-of-Arrays structure, where you have one object ExteriorFacets, containing the data for all facets in long vectors which must be indexed correctly, possibly through inlined helper methods in the class. In this particular example, ExteriorFacets could even be removed altogether and its members put directly in Mesh.

Since the performance loss of the Array-of-Objects approach comes from dereferencing pointers*, another option is to make the ExteriorFacet object a contiguous number of bytes in memory by changing all the data to static C-style arrays, like we did for Particle. It would then become a template of the number of geometric dimensions.

* Possibly also constructor and destructor calls, but that shouldn't be a problem here.

Metadata

Metadata

Assignees

Labels

performanceReduces run time, memory or disk usage

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions