[Bf-committers] Sloppy code, slowing down Blender

Campbell Barton ideasman42 at gmail.com
Wed Apr 9 03:01:51 CEST 2014

Hi, recently I noticed that Blender is slower then it was back in 2.4x
days when it comes to many objects (just empties).

I recall having 80'000 objects in a scene, while it was very slow to
duplicate, Blender was usable apart from that.

Two recent examples:

On a test with ~20,000 objects I found blender was continuesly looping
over all scenes (and set scenes recursively), to check if any of the
objects were speakers, to update their sound time.
Even when there were no speakers in the blend file. (Now theres a
quick check to avoid this in `sound_update_scene`)

Today I just stubmed upon `BKE_object_lod_update` being called on
every redraw for every 3DView for every object, in every set-scene
recursively and every dupli. Incase the game engine is enabled and
LOD's are used.

This stuff should really come up in code-review,
(I can take some blame for not reviewing the patch in this case...)

While I'm sure its not the main bottleneck in blenders viewport speed,
its just sloppy and can be easily avoided (skip the loop if the
game-engine is disabled for example, and only operate on objects which
are visible!).

Sometimes bad hacks are hard to avoid, in those cases at least add a
comment that the code is inefficient with some explanation why a
better method can't be used.

For now I'll ifdef out this code when the game engine is disabled, but
really I think we should be a bit better picking up on this stuff
especially when it effects all users.

- Campbell

More information about the Bf-committers mailing list