Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up ObjectHandle.close() #516

Open
jkotan opened this issue Nov 4, 2021 · 3 comments
Open

Speed up ObjectHandle.close() #516

jkotan opened this issue Nov 4, 2021 · 3 comments

Comments

@jkotan
Copy link
Collaborator

jkotan commented Nov 4, 2021

One more think which can be speed-up is ObjectHandle.close() which is called quite often. It can be done by avoiding calls to H5Iget_type and storing the object type in the class instance variable. It is unlikely that the type of the object has been changed.

@eugenwintersberger
Copy link
Collaborator

Do you experience any performance issues due to this method?

@jkotan
Copy link
Collaborator Author

jkotan commented Nov 30, 2021

Hi Eugen, since PR #510, #511, #512, #514 and #515 limited a number of created objects so the number of ObjectHandle.close() executions dropped down and it is no more the serious issue. However, according to callgrind in the example test code

    vector<long int> vc(1);
    for(size_t i = 0; i < 100000; i++) {
      vc[0] = static_cast<long int>(std::rand());
      dataset.resize({i + 1});
      selection.offset(0, i);
      dataset.write(vc, selection);
    }

the close() method takes 9.9 % of time (executed ones for each loop step by file_space selection destructor).
From that hdf5::ObjectHandle::get_type() takes more than 1/3 while H5Sclose takes ~ 2/3.
Creating this ticket I wanted to point out where one can improve the speed. In the above case get_type() takes ~ 3% so it is not so serious anymore.

@eugenwintersberger
Copy link
Collaborator

ok. I see. This are about 10% of the overall runtime. You are absolutely right one should deal with this.

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

No branches or pull requests

2 participants