FBX IO: Speed up export by multithreading array compression #105018
No reviewers
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#105018
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "Mysteryem/blender-addons:fbx_multithread_array_compression_pr"
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?
zlib.compress() releases the GIL so can be multithreaded.
This patch adds a context manager to FBXElem that temporarily enables
multithreading of the compression of added arrays, by using the recently
added utility to schedule CPU-bound tasks to run on separate threads.
On my Ryzen 7 3800x, exporting non-animated rigged humanoid models
typically results in about a 1.2 to 1.4 times faster export.
Exporting only simple geometry, such as many subdivided default cubes,
can be about 2 to 3 times faster.
The multithreading is also enabled for the
json2fbx.py
script.No changes are expected to the contents of exported files.
I'm open to ideas of better ways to temporarily enable the multithreading in FBXElem.
My only other idea was to set
FBXElem._add_compressed_array_helper_multi
toNone
inFBXElem
's class definition and temporarily set it to the wrapped function that schedules the compression tasks when needed._add_array_helper
would then be updated to always checkFBXElem._add_compressed_array_helper_multi is not None
when it needs to compress an array. If the check passes it'll useFBXElem._add_compressed_array_helper_multi
and if the check fails, it'll do the compression itself.This PR depends on #105017 (its changes are not included in this PR)
LGTM.
Actually, I think I prefer the context manager solution to control when the threaded compression is enabled.
Implementation might be a bit verbose and convoluted, but the usage of it looks much cleaner to me?
Unless I do not get exactly how your other idea would work.
The other idea was to avoid entirely swapping out existing methods. Rather than swapping out the method, the existing method would be updated to always check for whether a
_add_compressed_array_helper_multi
attribute on the class is notNone
and then call that function instead of the existing non-threaded code. The context manager, in that case, would temporarily set the_add_compressed_array_helper_multi
attribute on the class to the threaded function.