Page MenuHome

Speedup: DNA_elem_array_size
ClosedPublic

Authored by Jacques Lucke (JacquesLucke) on Dec 5 2018, 8:34 PM.

Details

Summary

I started learning how to do some basic performance profiling for Blender. I mostly tested loading scenes from Spring.

The DNA_elem_array_size function turned out to be relatively slow.
In my test the function was executed almost 11 million times and was responsible for 6.8% of the execution time.
This change roughly halved this time. I did two runs with and without this change (didn't do more because it takes forever).

Diff Detail

Repository
rB Blender

Event Timeline

Jacques Lucke (JacquesLucke) planned changes to this revision.Dec 6 2018, 9:28 AM
Jacques Lucke (JacquesLucke) added inline comments.
source/blender/makesdna/intern/dna_genfile.c
160

Just noticed that this assert is probably wrong. Will test when I'm in office.

  • fix and minor speedup

Just a side note: It is totally fine when the actual name also contains numbers. They will be discarded when the first [ comes.

I find that the best way to show the actual impact of this is to show the total amount of events callgrind measured when loading a specific file from Spring. I did the tests interleaved and multiple times.

Blender 2.8:
  35,022,073,098
  35,014,875,744
  35,026,930,037

Original version of this patch:
  33,595,021,176
  33,601,440,281

New version of this patch:
  33,544,262,187
  33,533,864,686

I'll leave the interpretation of the numbers up to you. But I think this local change reduces the total amount of executed instructions by a surprisingly large amount.

This revision is now accepted and ready to land.Dec 6 2018, 2:09 PM
This revision was automatically updated to reflect the committed changes.