Skip to content

Tiled JPEG2000 Decoder Performance Regression #53

Description

@Azure-Axolotl

Version

0.3.0 - 0.9.0

Describe the bug.

Updating from 0.2.0 to 0.3.0 results in a significant performance regression for large, tiled, JP2 images. Removing the cudaStreamWaitEvents around the tile decode step and restoring the looped stream wait event processing appears to resolve this performance hit. It appears that every release after 0.3.0 suffers from the same performance regression.

In order to observe a significant latency hit the Jp2 image must be relatively large and contain a large number of tiles. I have provided a code snippet demonstrating how to convert the Hurricane Alex Geotiff to a tiled JP2 file that meet both of these criteria. This new JP2 file is utilized in the minimum reproducible example.

conda install -c conda-forge --yes glymur openjpeg python=3.12
tiff2jp2 --tilesize 256 256 'Alex_2016-01-14_1300Z_(Geotiff).tif' Alex_2016-01-14_1300Z-256-tile.jp2

Running a decode operation on this sample image results in a 7x slowdown between the 0.2.0 and the 0.3.0 release. My team and I would be interested in a solution involving an asynchronous option for decoding tiles on the GPU to restore the performance of the 0.2.0 release.

Thanks!

Minimum reproducible example

from timeit import timeit
from nvidia import nvimgcodec
with open("Alex_2016-01-14_1300Z-256-tile.jp2", "rb") as f: dataset_bytes = f.read()
decode_params = nvimgcodec.DecodeParams(color_spec=nvimgcodec.ColorSpec.UNCHANGED, allow_any_depth=True, apply_exif_orientation=False,)
decoder = nvimgcodec.Decoder(backends=[nvimgcodec.Backend(nvimgcodec.GPU_ONLY)], max_num_cpu_threads=12, device_id=0,)
print(timeit("decoder.decode(dataset_bytes, params = decode_params)", globals=globals(), number=10))

Environment details

<details><summary>Click here to see environment details</summary><pre>                                                                                                                          
                                                                                                                                                                                                
     **git***                                                                                                                                                                                   
     Not inside a git repository                                                                                                                                                                
                                                                                                                                                                                                
     ***OS Information***                                                                                                                                                                       
     DISTRIB_ID=Ubuntu                                                                                                                                                                          
     DISTRIB_RELEASE=24.04                                                                                                                                                                      
     DISTRIB_CODENAME=noble                                                                                                                                                                     
     DISTRIB_DESCRIPTION="Ubuntu 24.04.4 LTS"                                                                                                                                                   
     PRETTY_NAME="Ubuntu 24.04.4 LTS"                                                                                                                                                           
     NAME="Ubuntu"                                                                                                                                                                              
     VERSION_ID="24.04"                                                                                                                                                                         
     VERSION="24.04.4 LTS (Noble Numbat)"                                                                                                                                                       
     VERSION_CODENAME=noble                                                                                                                                                                     
     ID=ubuntu                                                                                                                                                                                  
     ID_LIKE=debian                                                                                                                                                                             
     HOME_URL="https://www.ubuntu.com/"                                                                                                                                                         
     SUPPORT_URL="https://help.ubuntu.com/"                                                                                                                                                     
     BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"                                                                                                                                        
     PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"                                                                                                        
     UBUNTU_CODENAME=noble                                                                                                                                                                      
     LOGO=ubuntu-logo                                                                                                                                                                           
     Linux ip-10-19-193-27.us-gov-west-1.compute.internal 5.10.192-183.736.amzn2.x86_64 #1 SMP Wed Sep 6 21:15:41 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux                                       
                                                                                                                                                                                                
     ***GPU Information***                                                                                                                                                                      
     Thu Jul  2 19:07:53 2026                                                                                                                                                                   
     +---------------------------------------------------------------------------------------+                                                                                                  
     | NVIDIA-SMI 535.104.12             Driver Version: 535.104.12   CUDA Version: 12.2     |                                                                                                  
     |-----------------------------------------+----------------------+----------------------+                                                                                                  
     | GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |                                                                                                  
     | Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |                                                                                                  
     |                                         |                      |               MIG M. |                                                                                                  
     |=========================================+======================+======================|                                                                                                  
     |   0  Tesla T4                       On  | 00000000:00:1E.0 Off |                    0 |                                                                                                  
     | N/A   30C    P8              14W /  70W |      0MiB / 15360MiB |      0%      Default |                                                                                                  
     |                                         |                      |                  N/A |
     +-----------------------------------------+----------------------+----------------------+
     
     +---------------------------------------------------------------------------------------+
     | Processes:                                                                            |
     |  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
     |        ID   ID                                                             Usage      |
     |=======================================================================================|
     |  No running processes found                                                           |
     +---------------------------------------------------------------------------------------+
     
     ***CPU***
     Architecture:                       x86_64
     CPU op-mode(s):                     32-bit, 64-bit
     Address sizes:                      46 bits physical, 48 bits virtual
     Byte Order:                         Little Endian
     CPU(s):                             16
     On-line CPU(s) list:                0-15
     Vendor ID:                          GenuineIntel
     Model name:                         Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
     CPU family:                         6
     Model:                              85
     Thread(s) per core:                 2
     Core(s) per socket:                 8
     Socket(s):                          1
     Stepping:                           7
     BogoMIPS:                           4999.99
     Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves ida arat pku ospke avx512_vnni
     Hypervisor vendor:                  KVM
     Virtualization type:                full
     L1d cache:                          256 KiB (8 instances)
     L1i cache:                          256 KiB (8 instances)
     L2 cache:                           8 MiB (8 instances)
     L3 cache:                           35.8 MiB (1 instance)
     NUMA node(s):                       1
     NUMA node0 CPU(s):                  0-15
     Vulnerability Gather data sampling: Unknown: Dependent on hypervisor status
     Vulnerability Itlb multihit:        KVM: Mitigation: VMX unsupported
     Vulnerability L1tf:                 Mitigation; PTE Inversion
     Vulnerability Mds:                  Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown
     Vulnerability Meltdown:             Mitigation; PTI
     Vulnerability Mmio stale data:      Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown
     Vulnerability Retbleed:             Vulnerable
     Vulnerability Spec rstack overflow: Not affected
     Vulnerability Spec store bypass:    Vulnerable
     Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
     Vulnerability Spectre v2:           Mitigation; Retpolines, STIBP disabled, RSB filling
     Vulnerability Srbds:                Not affected
     Vulnerability Tsx async abort:      Not affected
     
     ***CMake***
     
     ***g++***
     
     ***nvcc***
     
     ***Python***
     /opt/conda/bin/python
     Python 3.12.13
     
     ***Environment Variables***
     PATH                            : /opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
     LD_LIBRARY_PATH                 :
     NUMBAPRO_NVVM                   :
     NUMBAPRO_LIBDEVICE              :
     CONDA_PREFIX                    :
     PYTHON_PATH                     :
     
     ***conda packages***
     /opt/conda/bin/conda
     # packages in environment at /opt/conda:
     #
     # Name                     Version          Build                 Channel
     _openmp_mutex              4.5              20_gnu                conda-forge
     _python_abi3_support       1.0              hd8ed1ab_2            conda-forge
     annotated-types            0.7.0            pyhd8ed1ab_1          conda-forge
     anyio                      4.14.1           pyhcf101f3_0          conda-forge
     archspec                   0.2.5            pyhd8ed1ab_0          conda-forge
     backports.zstd             1.6.0            py312h90b7ffd_0       conda-forge
     boltons                    25.0.0           pyhd8ed1ab_0          conda-forge
     brotli-python              1.2.0            py312hdb49522_1       conda-forge
     bzip2                      1.0.8            hda65f42_9            conda-forge
     c-ares                     1.34.6           hb03c661_0            conda-forge
     ca-certificates            2026.6.17        hbd8a1cb_0            conda-forge
     cached-property            1.5.2            hd8ed1ab_1            conda-forge
     cached_property            1.5.2            pyha770c72_1          conda-forge
     certifi                    2026.6.17        pyhd8ed1ab_0          conda-forge
     cffi                       2.0.0            py312h460c074_1       conda-forge
     charset-normalizer         3.4.7            pyhd8ed1ab_0          conda-forge
     colorama                   0.4.6            pyhd8ed1ab_1          conda-forge
     conda                      26.5.3           py312h20c3967_2       conda-forge
     conda-index                0.12.1           pyhd8ed1ab_0          conda-forge
     conda-libmamba-solver      26.4.2           pyhd8ed1ab_0          conda-forge
     conda-lockfiles            0.2.0            pyhd8ed1ab_0          conda-forge
     conda-package-handling     2.4.0            pyh7900ff3_2          conda-forge
     conda-package-streaming    0.12.0           pyhd8ed1ab_0          conda-forge
     conda-pypi                 0.10.1           py312h20c3967_2       conda-forge
     conda-rattler-solver       0.1.1            pyhcf101f3_0          conda-forge
     conda-self                 0.2.0            pyhd8ed1ab_0          conda-forge
     cpp-expected               1.3.1            h171cf75_0            conda-forge
     cpython                    3.12.13          py312hd8ed1ab_0       conda-forge
     distro                     1.9.0            pyhd8ed1ab_1          conda-forge
     exceptiongroup             1.3.1            pyhd8ed1ab_0          conda-forge
     filelock                   3.29.4           pyhd8ed1ab_0          conda-forge
     fmt                        12.1.0           hff5e90c_0            conda-forge
     frozendict                 2.4.7            pyh851646a_2          conda-forge
     glymur                     0.14.8           pyhd8ed1ab_0          conda-forge
     h11                        0.16.0           pyhcf101f3_1          conda-forge
     h2                         4.3.0            pyhcf101f3_0          conda-forge
     hpack                      4.1.0            pyhd8ed1ab_0          conda-forge
     httpcore                   1.0.9            pyh29332c3_0          conda-forge
     httpx                      0.28.1           pyhd8ed1ab_0          conda-forge
     hyperframe                 6.1.0            pyhd8ed1ab_0          conda-forge
     icu                        78.3             h33c6efd_0            conda-forge
     idna                       3.17             pyhcf101f3_0          conda-forge
     imageio                    2.37.0           pyhfb79c49_0          conda-forge
     importlib-metadata         9.0.0            pyhcf101f3_0          conda-forge
     jinja2                     3.1.6            pyhcf101f3_1          conda-forge
     jsonpatch                  1.33             pyhd8ed1ab_1          conda-forge
     jsonpointer                3.1.1            pyhcf101f3_0          conda-forge
     keyutils                   1.6.3            hb9d3cd8_0            conda-forge
     krb5                       1.22.2           ha1258a1_0            conda-forge
     lcms2                      2.19.1           h0c24ade_1            conda-forge
     ld_impl_linux-64           2.45.1           default_hbd61a6d_102  conda-forge
     lerc                       4.1.0            hdb68285_0            conda-forge
     libarchive                 3.8.7            gpl_hc2c16d8_101      conda-forge
     libblas                    3.11.0           8_h4a7cf45_openblas   conda-forge
     libcblas                   3.11.0           8_h0358290_openblas   conda-forge
     libcurl                    8.20.0           hcf29cc6_0            conda-forge
     libdeflate                 1.25             h17f619e_0            conda-forge
     libedit                    3.1.20250104     pl5321h7949ede_0      conda-forge
     libev                      4.33             hd590300_2            conda-forge
     libexpat                   2.8.1            hecca717_0            conda-forge
     libffi                     3.5.2            h3435931_0            conda-forge
     libfreetype                2.14.3           ha770c72_0            conda-forge
     libfreetype6               2.14.3           h73754d4_0            conda-forge
     libgcc                     15.2.0           he0feb66_19           conda-forge
     libgcc-ng                  15.2.0           h69a702a_19           conda-forge
     libgfortran                15.2.0           h69a702a_19           conda-forge
     libgfortran5               15.2.0           h68bc16d_19           conda-forge
     libgomp                    15.2.0           he0feb66_19           conda-forge
     libiconv                   1.18             h3b78370_2            conda-forge
     libjpeg-turbo              3.1.4.1          hb03c661_0            conda-forge
     liblapack                  3.11.0           8_h47877c9_openblas   conda-forge
     liblzma                    5.8.3            hb03c661_0            conda-forge
     libmamba                   2.5.0            hd28c85e_0            conda-forge
     libmamba-spdlog            2.5.0            h12fcf84_0            conda-forge
     libmambapy                 2.5.0            py312h1ca65c7_0       conda-forge
     libnghttp2                 1.68.1           h877daf1_0            conda-forge
     libnsl                     2.0.1            hb9d3cd8_1            conda-forge
     libopenblas                0.3.33           pthreads_h94d23a6_0   conda-forge
     libpng                     1.6.58           h421ea60_0            conda-forge
     libsolv                    0.7.39           h9463b59_0            conda-forge
     libsqlite                  3.53.1           h0c1763c_0            conda-forge
     libssh2                    1.11.1           hcf80075_0            conda-forge
     libstdcxx                  15.2.0           h934c35e_19           conda-forge
     libtiff                    4.7.1            h9d88235_1            conda-forge
     libuuid                    2.42.1           h5347b49_0            conda-forge
     libwebp-base               1.6.0            hd42ef1d_0            conda-forge
     libxcb                     1.17.0           h8a09558_0            conda-forge
     libxcrypt                  4.4.36           hd590300_1            conda-forge
     libxml2                    2.15.3           h49c6c72_0            conda-forge
     libxml2-16                 2.15.3           hca6bf5a_0            conda-forge
     libxslt                    1.1.43           h711ed8c_1            conda-forge
     libzlib                    1.3.2            h25fd6f3_2            conda-forge
     lxml                       6.1.1            py312h63ddcf0_0       conda-forge
     lz4-c                      1.10.0           h5888daf_1            conda-forge
     lzo                        2.10             h280c20c_1002         conda-forge
     mamba                      2.5.0            h9835478_0            conda-forge
     markupsafe                 3.0.3            py312h8a5da7c_1       conda-forge
     menuinst                   2.5.1            py312h20c3967_0       conda-forge
     msgpack-python             1.2.1            py312h0a2e395_1       conda-forge
     ncurses                    6.6              hdb14827_0            conda-forge
     nlohmann_json-abi          3.12.0           h0f90c79_1            conda-forge
     numpy                      2.5.0            py312h33ff503_0       conda-forge
     nvidia-nvimgcodec-cu12     0.2.0.7          pypi_0                pypi
     nvidia-nvjpeg-cu12         12.3.3.54        pypi_0                pypi
     openjpeg                   2.5.4            h55fea9a_0            conda-forge
     openssl                    3.6.3            h35e630c_0            conda-forge
     packaging                  26.2             pyhc364b38_0          conda-forge
     pillow                     12.3.0           py312h50c33e8_0       conda-forge
     pip                        26.1.2           pyh8b19718_0          conda-forge
     platformdirs               4.10.0           pyhcf101f3_0          conda-forge
     pluggy                     1.6.0            pyhf9edf01_1          conda-forge
     pthread-stubs              0.4              hb9d3cd8_1002         conda-forge
     py-rattler                 0.25.0           py310h70157a2_1       conda-forge
     pybind11-abi               11               hc364b38_1            conda-forge
     pycosat                    0.6.6            py312h4c3975b_3       conda-forge
     pycparser                  3.0              pyhcf101f3_0          conda-forge
     pydantic                   2.13.4           pyhcf101f3_0          conda-forge
     pydantic-core              2.46.4           py312h868fb18_0       conda-forge
     pyproject_hooks            1.2.0            pyhd8ed1ab_1          conda-forge
     pysocks                    1.7.1            pyha55dd90_7          conda-forge
     python                     3.12.13          hd63d673_0_cpython    conda-forge
     python-build               1.5.0            pyhc364b38_0          conda-forge
     python-gil                 3.12.13          hd8ed1ab_0            conda-forge
     python-installer           1.0.1            pyh332efcf_0          conda-forge
     python_abi                 3.12             8_cp312               conda-forge
     readline                   8.3              h853b02a_0            conda-forge
     reproc                     14.2.7.post0     hb03c661_1            conda-forge
     reproc-cpp                 14.2.7.post0     hecca717_1            conda-forge
     requests                   2.34.2           pyhcf101f3_0          conda-forge
     ruamel.yaml                0.18.17          py312h5253ce2_2       conda-forge
     ruamel.yaml.clib           0.2.15           py312h5253ce2_1       conda-forge
     setuptools                 82.0.1           pyh332efcf_0          conda-forge
     simdjson                   4.2.4            hb700be7_0            conda-forge
     sniffio                    1.3.1            pyhd8ed1ab_2          conda-forge
     spdlog                     1.17.0           hab81395_1            conda-forge
     tk                         8.6.13           noxft_h366c992_103    conda-forge
     tomli                      2.4.1            pyhcf101f3_0          conda-forge
     tomli-w                    1.2.0            pyhd8ed1ab_0          conda-forge
     tqdm                       4.67.3           pyh8f84b5b_0          conda-forge
     truststore                 0.10.4           pyhcf101f3_0          conda-forge
     typing-extensions          4.16.0           h69aa097_0            conda-forge
     typing-inspection          0.4.2            pyhcf101f3_2          conda-forge
     typing_extensions          4.16.0           pyhcf101f3_0          conda-forge
     tzdata                     2025c            hc9c84f9_1            conda-forge
     unearth                    0.18.2           pyhd8ed1ab_0          conda-forge
     urllib3                    2.7.0            pyhd8ed1ab_0          conda-forge
     wheel                      0.47.0           pyhd8ed1ab_0          conda-forge
     xorg-libxau                1.0.12           hb03c661_1            conda-forge
     xorg-libxdmcp              1.1.5            hb03c661_1            conda-forge
     yaml-cpp                   0.8.0            h3f2d84a_0            conda-forge
     zipp                       4.1.0            pyhcf101f3_0          conda-forge
     zlib-ng                    2.3.3            hceb46e0_1            conda-forge
     zstandard                  0.25.0           py312h5253ce2_1       conda-forge
     zstd                       1.5.7            hb78ec9c_6            conda-forge
     
</pre></details>

Relevant log output

Other/Misc.

NOTE: The provided environment details pertain to the 0.2.0 release. Please rerun the minimum reproducible example after installing the 0.3.0 release.

pip install nvidia-nvjpeg2k-cu12==0.8.0.38
pip install nvidia-nvimgcodec-cu12==0.3.0.5

NOTE: All of the provided code was run inside the docker image condaforge/miniforge3:26.3.2-3.

Check for duplicates

  • I have searched the open bugs/issues and have found no duplicates for this bug report

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions