Improve name conflict handling in ID management #73412
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
7 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#73412
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?
Commits
d840658078
,2aab727009
,4cc8201a65
, and46607bc09d
already made things significantly faster here, at least when dealing with large amounts of data-blocks.Going further will require caching info about already used names (more precisely, used base names, and used suffix numbers).
Proposal
Use a GHash per ID type, stored in
Main
, using base names as keys, and storing as values a structure to help quickly finding the best available number.Using only base names as keys will seriously reduce the memory usage of the whole cache, in case of massive amounts of IDs with same base name. And avoid lots of trial & failure while searching for an available number suffix.
Those hashes will have to be kept up-to-date all the time, as building them on demand would require way too much computations. This should not be too difficult though, code affecting ID's names is small and well confined. ID deletion code shall also update that cache.
Regarding Numbering
Current approach is to ensure we always get the smallest available number up to a specific value (around 1K in current code), then we just use smallest value after last one used (i.e. do not re-use freed numbers, so if e.g. we have
Object
toObject.2000
fully used by 2k objects, and deleteObject.1500
, then add a new one, it will getObject.2001
as name).We can probably efficiently do that for an arbitrary amount of numbers by storing bitflags (using chunks, maybe single 32bits integers, and a mempool) to tag used numbers (that would add about one extra bit of memory per ID). Using a n-tree structure should help with quickly finding an available number then (by greatly reducing the amount of comparisons needed to find the smallest available one).
Changed status from 'Needs Triage' to: 'Confirmed'
Added subscriber: @mont29
#90052 was marked as duplicate of this issue
Added subscriber: @Moult
Added subscribers: @marty3000, @PratikPB2123, @lichtwerk, @kursadk
Added subscriber: @ckohl_art
Added subscriber: @aras_p
I'll try to do this, :fingers_crossed:
Added subscriber: @Raimund58
Added subscriber: @Dangry
Changed status from 'Confirmed' to: 'Resolved'
Design as outlined here was implemented for Blender 3.3 in D14162. Possible follow up work: address "sort IDs by name" performance, perhaps by having functions that create a whole batch of IDs at once, and do the sorting in a more optimal way.