From 608ad092e52e2275ff6d1c373d7cdb8dbf75e7c0 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 19 May 2025 12:12:56 +0200 Subject: [PATCH] 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. --- client/ayon_core/lib/transcoding.py | 10 +++++++++- client/pyproject.toml | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/lib/transcoding.py b/client/ayon_core/lib/transcoding.py index 8c84e1c4dc..3d51f48d08 100644 --- a/client/ayon_core/lib/transcoding.py +++ b/client/ayon_core/lib/transcoding.py @@ -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([ diff --git a/client/pyproject.toml b/client/pyproject.toml index edf7f57317..7af9ef1e04 100644 --- a/client/pyproject.toml +++ b/client/pyproject.toml @@ -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]