Adding large number of objects much slower in 2.80 #66613
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
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#66613
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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: Arch Linux
Graphics card: GTX Titan
Blender Version
Broken: 2.80.74 (
9c5d54bfaf
, binary from blender.org)Worked: 2.79.7 (Arch Linux package)
Short description of error
Adding a large number of objects is taking much more time with 2.80 compared to 2.79
Exact steps for others to reproduce the error
With the attached script (which just calls
bpy.ops.mesh.primitive_cube_add
in a loop with random locations):So 2.80 takes roughly 3.8x as much time, although it is slightly less exponential in behaviour compared to 2.79.
thousands_of_objects.py
Added subscriber: @PaulMelis
Added subscriber: @mano-wii
Calling an operator within such a large loop is not a good practice.
You should think of better ways to achieve the same result.
Since this is a regression I will confirm as a bug, however we have many other bugs to keep on track, so it will have low priority.
Added subscriber: @brecht
Changed status from 'Open' to: 'Archived'
Definitely we can improve performance in many ways, but I do not consider this a bug at all. We make no performance guarantees about using operators as a programming API to add thousands of objects.
Okay, I used the cube add operator in the test as it was convenient, figuring it would show the behaviour I was seeing when creating meshes. Turns out the difference is much smaller in the latter case, but still quite a big slowdown in 2.8 compared to 2.7 (and higher memory usage). See the attached script, which uses
foreach_set()
as the fastest way I know to create geometry from a bpy script. This again creates lots (20,000) of mesh objects in a loop, simulating an import script that does more-or-less the same. The mesh objects are simple quads to focus on the overhead of object creation. Here's some results (note: different blender versions that above, as this is on my home system):65b2cc2301
)Some observations:
The actual real-life case this is all coming from was the 55GB .obj file somebody gave me that was exported from Rhino containing 120,000 OBJ groups. Blender did not manage to import it before running out of memory, even on a system with 96GB RAM :) So I started doing some (micro-)benchmarking and figured I'd report it. In general, I would expect performance and memory regressions from 2.7 to 2.8 to be of interest to you guys. Again, I understand that the Python API is not optimized for all kinds of wacky large scene creation, but since the current importers are (still, cf GSOC) based on the same API regressions are felt all across the board for large scenes. Plus, the Python API is in most cases the only way to do this kind of stuff, as extending Blender with C/C++ takes significant effort to get to know the code base and way of doing things (a C/C++ plugin API would be nice ;-)).
By the way, for some reason the output of the
bpy.ops.wm.memory_statistics()
call that prints the memory stats gets printed before the other output in 2.8 when redirecting to file on Linux, even though it is the last statement in the script. Did the stdout/stderr caching change in 2.8?thousands_of_meshes.py
Improving performance with many object is one of the items listed here #63728 (Data, Assets & I/O Module).
But we don't organize that by bug reports, it's not efficient to analyze or explain to everyone why something takes a certain amount of time or memory in some specific case, as long as it's within something like a 2x or 3x range.
Added subscriber: @mont29
I’d bet differences in performances here are mostly due to the 'linking to collection' step, which is much more expensive that the 'linking to scene' equivalent we had in 2.79. Code in 2.80 is not necessarily fully optimal there yet, but mainly, 2.8 system is much more complex and requires lots more checks and caching operations when linking (especially the
BKE_main_collection_sync()
which is ran on every object adding, and will become more and more expensive with the amount of existing objects)…