Python API: Huge performance degradation in Blender 2.8 #63662
Labels
No Label
Interest
Animation & Rigging
Interest
Blender Cloud
Interest
Collada
Interest
Core
Interest
Documentation
Interest
Eevee & Viewport
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
Import and Export
Interest
Modeling
Interest
Modifiers
Interest
Nodes & Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds, Tests & Devices
Interest
Python API
Interest
Rendering & Cycles
Interest
Sculpt, Paint & Texture
Interest
Translations
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Meta
Good First Issue
Meta
Papercut
Module
Add-ons (BF-Blender)
Module
Add-ons (Community)
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#63662
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Windows 7, 64bit
Graphics card:
Blender Version
Broken: (example: 2.80, edc1b0167518)
Worked: (optional) 2.79b
Short description of error
I'm using Blender as a 3D live view controlled from an external application (see https://developer.blender.org/T62051 for more details).
I just noticed that, compared to Blender 2.79, some operations are up to 20x slower in 2.80!
Here is an example:
Interestingly, these operations are only slow when I have loaded my 3D model (stats: Verts ~120.000, Faces ~200.000, Tris: ~250.000, Objects: ~1000).
When I run this example in an empty Blender file with 2.80 it is always fast (max 4ms, usually faster). In Blender 2.79 (code attached) with my model loaded it performs still very good (4ms to 8ms). However, running this on 2.80 with my model loaded it takes 60 to 85 ms!
I guess this is related to the new renderer. For a workaround it would be perfectly fine if I could disable rendering during my timer callbacks (if that helps), but I couldn't find anything in the API docs.
example-27.py
Added subscriber: @schlamar
Added subscriber: @JacquesLucke
This is in an almost empty scene.
In your case, almost all time is spent in
BKE_scene_graph_update_tagged
. This is triggered by the newly created object.Not sure if there is any way to avoid this currently.
Please note this is unrelated to application timers. The issue also shows if the
add_cylinder
is called directly without a custom context:So I assume all Python plugins are affected by this performance regression!
You can reproduce this for example with the classroom demo (https://download.blender.org/demo/test/classroom.zip). With this example
primitive_cylinder_add
is ~10x slower on 2.80.I'm not sure if I read your performance graph correctly, but isn't the scene update called before the execution of the operator?
Running the script multiple times in an empty scene, performance gets worse for every new object. Starting with ~2ms for the first object, duration with 100 added cylinders is ~12ms.
Any updates here? I think this is a high priority issue for the 2.80 release.
It looks like this is an exponential performance degradation, so with very high detailed models with a lot of objects Python plugins could be even unusable.
This issue still exists in the final 2.80 release.
primitive_cylinder_add
takes ~40 ms in 2.80 running in the classroom demo. On 2.79, it only takes around 4 ms.Added subscriber: @ideasman42
Added subscriber: @mano-wii
Changed status from 'Confirmed' to: 'Archived'
Operators add a lot of overhead to a script. For example, they add memory-consuming undo stacks.
Therefore, they should be avoided in loops or functions called very often.
You should look for other ways to create a primitive cylinder other than thougth an operator.
Also there are optimization plans in this area (IDs) -> https://code.blender.org/2020/01/2020-blender-big-projects/
Although it is slower than 2.79, this is not considered a bug as such a solution should be avoided in scripts.