Nodes: Slightly improve editor drawing performance with large node trees #130239

Merged
Hans Goudey merged 5 commits from HooglyBoogly/blender:ui-block-begin-end-args into main 2024-11-14 16:04:54 +01:00
Member

Avoid retrieving context data for every single node which can be
expensive when there are thousands of nodes. In the "Mouse House"
test file I observed a 13% improvement in drawing timings.

Avoid retrieving context data for every single node which can be expensive when there are thousands of nodes. In the "Mouse House" test file I observed a 13% improvement in drawing timings.
Hans Goudey added 1 commit 2024-11-13 21:05:00 +01:00
Nodes: Slightly improve editor drawing performance with large node trees
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
0d6b487b2c
Avoid retrieving context data for every single node which can be
expensive when there are thousands of nodes. In the "Mouse House"
test file I observed a 13% improvement in drawing timings.
Author
Member

@blender-bot build

@blender-bot build
Hans Goudey requested review from Jacques Lucke 2024-11-13 21:33:00 +01:00
Jacques Lucke requested changes 2024-11-14 11:25:20 +01:00
Dismissed
Jacques Lucke left a comment
Member

Seems fine for now. I guess it would also be nice to solve this more generally and to make retrieving context faster in these common cases? It feels like it should be fairly straight forward to cache the main/scene/... on the context when it has been retrieved the first time. Changes to the context could just invalidate the cache.

Seems fine for now. I guess it would also be nice to solve this more generally and to make retrieving context faster in these common cases? It feels like it should be fairly straight forward to cache the main/scene/... on the context when it has been retrieved the first time. Changes to the context could just invalidate the cache.
@ -344,3 +354,2 @@
const bNode &node = *nodes[i];
std::string block_name = "node_" + std::string(node.name);
uiBlock *block = UI_block_begin(&C, CTX_wm_region(&C), std::move(block_name), UI_EMBOSS);
uiBlock *block = UI_block_begin(&C, scene, window, region, std::string(node.name), UI_EMBOSS);
Member

The node name thing seems unrelated. I could imagine this causing problems if there are other uiBlock that happen to have the same name as a node. Better don't include this change here.

The node name thing seems unrelated. I could imagine this causing problems if there are other `uiBlock` that happen to have the same name as a node. Better don't include this change here.
Author
Member

I don't think we add anymore blocks to the main region besides the nodes. But sure, I'll remove it from this PR.

I don't think we add anymore blocks to the main region besides the nodes. But sure, I'll remove it from this PR.
HooglyBoogly marked this conversation as resolved
@ -4799,6 +4850,7 @@ static void node_draw_nodetree(const bContext &C,
Span<uiBlock *> blocks,
bNodeInstanceKey parent_key)
{
SCOPED_TIMER_AVERAGED(__func__);
Member

leftover timer

leftover timer
HooglyBoogly marked this conversation as resolved
Hans Goudey added 4 commits 2024-11-14 14:23:00 +01:00
Author
Member

Yeah, I might look into that caching also. This felt simple enough to be worth it though, it's maybe the only place where we're creating an arbitrary number of uiBlocks so doing something a bit different felt reasonable.

Yeah, I might look into that caching also. This felt simple enough to be worth it though, it's maybe the only place where we're creating an arbitrary number of uiBlocks so doing something a bit different felt reasonable.
Hans Goudey requested review from Jacques Lucke 2024-11-14 14:23:42 +01:00
Jacques Lucke approved these changes 2024-11-14 15:38:17 +01:00
Hans Goudey merged commit 6c3ac28eb3 into main 2024-11-14 16:04:54 +01:00
Hans Goudey deleted branch ui-block-begin-end-args 2024-11-14 16:04:57 +01:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
2 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#130239
No description provided.