﻿# Parallel EXR decoding: coordinate the global pool with per-file thread limits

Configure OpenEXR Python decoding concurrency with the shared worker pool and per-file limits, while preserving buffer ownership and measuring input-stage throughput.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-openexr-python-global-pool-file-thread-budget/
Language: en

## Separate two layers of parallelism

A training pipeline may use several input workers while the image library also starts decode threads. These are different scheduling layers. More concurrency can improve throughput, but it can also contend for CPU time, memory bandwidth or storage. Before adjusting counts, identify whether the slow stage is compressed input, decompression, array transformation or transfer to the GPU. A busy processor alone does not establish that the model receives batches sooner.

## Initialize the library pool deliberately

The [OpenEXR Python reference](https://openexr.com/en/latest/python.html) documents threading controls introduced in version 3.5. The global thread count configures a process-wide library pool; a per-file `num_threads` setting limits use of that pool. Setting only a positive per-file value does not create workers when the global pool is disabled. Configure global state at process initialization and verify the installed binding supports the controls before relying on them in a deployed loader.

## Share capacity across simultaneous files

The [C++ I/O guide](https://openexr.com/en/latest/ReadingAndWritingImageFiles.html) explains why simultaneous files need to share library worker capacity. A per-file budget can prevent one large image from consuming all available decode workers while another file waits. Account for separate processes as separate resource consumers rather than assuming the pool spans the entire training job. Measure the aggregate budget under the real number of loader processes and include the CPU needed by later preprocessing operations.

## Preserve buffer ownership during I/O

The Python documentation states that releasing the interpreter lock during I/O does not make returned dictionaries or pixel arrays safe for concurrent mutation. The [NumPy thread-safety guide](https://numpy.org/doc/stable/reference/thread_safety.html) likewise warns about shared mutable arrays. Give each concurrent operation its own file object and buffers, or serialize access appropriately. Do not resize the global pool while file I/O is active, and do not normalize an array concurrently with writing it.

## Measure useful input throughput

Compare a bounded set of pool and per-file configurations using representative images, recording batch readiness, CPU use and peak RAM. Keep GPU execution outside the decode timing when isolating the bottleneck. The guides to [render capacity](/journal/render-farm-idle-gpus/) and [renderer compatibility](/journal/gpu-llm-renderer-compatibility-matrix/) provide related context. Choose concurrency from measured end-to-end benefit and stable ownership, rather than treating a larger thread setting as an automatic improvement in training performance.
