Skip to content

Improve validate() performance for large arrays of structures#139

Open
maarten-ic wants to merge 1 commit into
iterorganization:developfrom
maarten-ic:performance/validate
Open

Improve validate() performance for large arrays of structures#139
maarten-ic wants to merge 1 commit into
iterorganization:developfrom
maarten-ic:performance/validate

Conversation

@maarten-ic

Copy link
Copy Markdown
Collaborator

Prevent an expensive _path calculation when it is not required.


Speeds up ids.validate() by a factor 5 on SDCC for the example below:

import timeit
import imas
from imas.ids_defs import CLOSEST_INTERP

uri = "imas:hdf5?path=/home/ITER/tribolp/public/imasdb/interp/105027/from_predictMagnetics_5kHz"
with imas.DBEntry(uri, "r") as entry:
    mag = entry.get_slice("magnetics", 0, CLOSEST_INTERP)

print(timeit.repeat("mag.validate()", number=10, globals=globals()))

The changes in this PR reduce the time for a single validate() from 370 ms to 66 ms on an SDCC login node with toolchain 2023b.

Prevent an expensive `_path` calculation when it is not required.
@maarten-ic maarten-ic changed the title Improve performance for large arrays of structures Improve validate() performance for large arrays of structures Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant