WIP: Core: use generic copy-on-write system to avoid unnecessary data copies #104471

Closed
Jacques Lucke wants to merge 66 commits from JacquesLucke/blender:temp-copy-on-write into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

This patch adds copy-on-write support in a few places. The main goal right now is to find related issues and to figure out what improvements we can expect. For more details, see #95845.

What's included in the patch so far:

  • CustomData refactor that allows sharing attribute layers. To properly implement this, the API had to be changed a bit as well.
  • Integration with the undo system, which fixes #98574.
  • RNA API that allows addons/cycles to take ownership of arrays by calling Attribute.cow.add_user if the array is shareable.
  • GeometryComponent uses the same copy-on-write system, instead of what it used before.
  • AnonymousAttributeID also uses the system, but doesn't really have to (because the data is immutable anyway). It was just easier to use the same system for now.

Possible regressions:

  • Had to disable saving undo mem-files to disk when Blender quits. Instead it uses a normal file-save now. This might be a bit slower. I didn't benchmark that yet. Might be ok if it's still fast enough since this only affects the time Blender takes to close.
  • Had to disable USE_ARRAY_STORE in editmesh_undo.cc because in its current form it doesn't work well with attribute sharing. It might be possible to improve this, but I still have to check whether its worth it or whether that can be removed completely.

Planned Tests:

  • Test if cycles can take (shared) ownership of attribute arrays through the RNA API. Currently the Attribute class is accessed on many different abstraction levels, making it a bit harder.
This patch adds copy-on-write support in a few places. The main goal right now is to find related issues and to figure out what improvements we can expect. For more details, see #95845. What's included in the patch so far: * `CustomData` refactor that allows sharing attribute layers. To properly implement this, the API had to be changed a bit as well. * Integration with the undo system, which fixes #98574. * RNA API that allows addons/cycles to take ownership of arrays by calling `Attribute.cow.add_user` if the array is shareable. * `GeometryComponent` uses the same copy-on-write system, instead of what it used before. * `AnonymousAttributeID` also uses the system, but doesn't really have to (because the data is immutable anyway). It was just easier to use the same system for now. Possible regressions: * Had to disable saving undo mem-files to disk when Blender quits. Instead it uses a normal file-save now. This might be a bit slower. I didn't benchmark that yet. Might be ok if it's still fast enough since this only affects the time Blender takes to close. * Had to disable `USE_ARRAY_STORE` in `editmesh_undo.cc` because in its current form it doesn't work well with attribute sharing. It might be possible to improve this, but I still have to check whether its worth it or whether that can be removed completely. Planned Tests: * Test if cycles can take (shared) ownership of attribute arrays through the RNA API. Currently the `Attribute` class is accessed on many different abstraction levels, making it a bit harder.
Jacques Lucke added 50 commits 2023-02-08 14:52:52 +01:00
Jacques Lucke closed this pull request 2023-02-08 18:48:39 +01:00
Some checks failed
buildbot/vexp-code-patch-coordinator Build done.

Pull request closed

Sign in to join this conversation.
No reviewers
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
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#104471
No description provided.