Page MenuHome

Transform: Support for a customizable and resizable 'struct TransData'
Changes PlannedPublic

Authored by Germano Cavalcante (mano-wii) on Jun 2 2020, 5:15 AM.

Details

Reviewers
None
Summary

This patch is a proposal to save memory and improve performance in the transform code.
And it is also a step to better solve T70873 (deduplicating code and saving memory).

The core of this solution is in the file transform_data.h.
Basically this API allows to allocate a customized TransData with only the members that will be used for the chosen transform mode.

This patch replaces all references of td->any_member to TD(td, tde, any_member).
td being a block that describes how to read tde and tde a pointer to where the component values are allocated.

Performance is not affected. In fact, the solution of this "dynamic" struct is slightly more efficient than the "static" struct.
Here the results comparing the performance of Translate, Rotate and Scale modes with all TransData members deliberately allocated:

Translate:Dynamic Struct:Static Struct:
TIME CONVERT0.0868770.092606
TIME MODE0.0434320.044919
TIME END0.0603700.063259
Rotate:Dynamic Struct:Static Struct:
TIME CONVERT0.0885340.093524
TIME MODE0.0571130.060536
TIME END0.0618920.057728
Scale:Dynamic Struct:Static Struct:
TIME CONVERT0.0837900.090281
TIME MODE0.0645080.065083
TIME END0.0597830.062925

And here are the results of transforming a mesh but with TransData without the ob, con, ext, hdata, val and ival members:

Translate:Dynamic Struct:Static Struct:
TIME CONVERT0.0736050.093007
TIME MODE0.0367120.049270
TIME END0.0515020.068967
Rotate:Dynamic Struct:Static Struct:
TIME CONVERT0.0781530.093721
TIME MODE0.0566140.061064
TIME END0.0524340.060353
Scale:Dynamic Struct:Static Struct:
TIME CONVERT0.0723160.091699
TIME MODE0.0588380.063039
TIME END0.0513080.057378

It is an improvement in performanse around 20% and still have room for more.

But while it has the advantage of performance and memory usage, there are other points that need to be considered:

  • It can complicate the code investigation since we are no longer working with a conventional object and we cannot use the IDE to access the definition of each member or its values.
  • It can induce errors since the coder can forget that a component is optional and not add a condition to its existence before.

Diff Detail

Repository
rB Blender
Branch
transform_data_dynamic (branched from master)
Build Status
Buildable 8320
Build 8320: arc lint + arc unit

Event Timeline

Germano Cavalcante (mano-wii) requested review of this revision.Jun 2 2020, 5:15 AM
Germano Cavalcante (mano-wii) retitled this revision from Transform: Adapt new dynamic TransData struct to Transform: Support for a customizable and resizable 'struct TransData'.Jun 2 2020, 5:18 AM
Germano Cavalcante (mano-wii) planned changes to this revision.Aug 31 2020, 3:11 PM