Sorting of members of a compound type

Hi,

Platform:Ubuntu Linux 18.04
HDF version:1.12.0 compiled from source.

I am trying to use compound types writing a field at a time (this is necessary for backwards compatibility with our software).
This works but there is a performance issue which I have narrowed down using a profiler to HDstrcmp() in H5T_cmp() in H5T.c.
The sorting by name happens repeatedly for each write even though the members of the compound type are the same each time.
There is a field called ‘sorted’ in H5T_compnd_t and it gets set to H5T_SORT_VALUE by H5T__sort_value().

So my question is: Would you accept a change to avoid sorting repeatedly? Or would you be willing to implement such a change?

My first attempt (sort them by name initially and don’t sort them in H5T_cmp()) breaks my tests because the order of the members by value seems to be relied upon when writing data. A possible solution is to store the index arrays used for sorting in the compound-specific part of the type and fill them once.

Cheers,

-Tony

We would 100% accept a patch that makes the sorting more efficient :slight_smile:

That’s great.

I notice that one of the tests fails with a SEGV. Is this expected?

Cheers,

-Tony

I’m not sure which test you are talking about, but the answer is probably “no”. Tests generally shouldn’t segfault.