Improves transcoding performance and memory usage

Configures OpenImageIO (OIIO) to use a percentage of available memory as a cache.
This improves transcoding performance by reducing disk I/O. Also, this change adds
the 'psutil' package as a dependency to gather system memory information. It also
enables multithreading in OIIO to further enhance performance.
This commit is contained in:
Jakub Jezek 2025-05-19 12:12:56 +02:00
parent fcd6bfdf0f
commit 608ad092e5
No known key found for this signature in database
GPG key ID: 06DBD609ADF27FD9
2 changed files with 10 additions and 1 deletions

View file

@ -6,6 +6,7 @@ import collections
import tempfile
import subprocess
import platform
import psutil
from typing import Optional
import xml.etree.ElementTree
@ -1009,12 +1010,19 @@ def convert_colorspace(
# Collect channels to export
input_arg, channels_arg = get_oiio_input_and_channel_args(input_info)
# Prepare subprocess arguments
# Use 50% of available memory for cache (in bytes)
available_memory = psutil.virtual_memory().available
cache_size = int(available_memory * 0.5)
# Prepare subprocess arguments
oiio_cmd = get_oiio_tool_args(
"oiiotool",
# Don't add any additional attributes
"--nosoftwareattrib",
"--colorconfig", config_path
"--threads", str(os.cpu_count()),
"--cache", str(cache_size),
"--colorconfig", config_path,
)
oiio_cmd.extend([

View file

@ -9,6 +9,7 @@ jsonschema = "^2.6.0"
pyblish-base = "^1.8.11"
speedcopy = "^2.1"
six = "^1.15"
psutil = "^5.9.0"
qtawesome = "0.7.3"
[ayon.runtimeDependencies]