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

Cache existing chunks in frame 0. #325

Merged
merged 2 commits into from
Jan 22, 2024
Merged

Conversation

joaander
Copy link
Member

@joaander joaander commented Jan 22, 2024

Description

Cache the results of chunk_exists calls from frame 0.

Motivation and Context

This increases performance. In cases where users write many values that match defaults, the previous code would check (for every single chunk) whether that chunk is present in frame 0:

DEBUG:gsd.hoomd:skipping data chunk, matches frame 0: particles/orientation
DEBUG:gsd.fl:chunk exists: test.gsd - particles/velocity
DEBUG:gsd.hoomd:writing data chunk: particles/velocity
DEBUG:gsd.fl:write chunk: test.gsd - particles/velocity

The chunk_exists call triggers an implicit flush which decreases write performance significantly.

After this change, the chunk_exists call is made once for frame 0 and the results are reused, resulting in no extra chunk_exists calls:

DEBUG:gsd.hoomd:skipping data chunk, matches frame 0: particles/orientation
DEBUG:gsd.hoomd:writing data chunk: particles/velocity
DEBUG:gsd.fl:write chunk: test.gsd - particles/velocity

How Has This Been Tested?

Existing tests pass.

hoomd-benchmarks.py does not trigger the extra chunk_exists calls, so it does not show any performance improvement. Use-cases that trigger it excessively should see improvement.

Checklist:

  • I have reviewed the Contributor Guidelines.
  • I agree with the terms of the GSD Contributor Agreement.
  • My name is on the list of contributors (doc/credits.rst) in the pull request source branch.
  • I have added a change log entry to CHANGELOG.rst.

Base automatically changed from fix-initial-frame to trunk-patch January 22, 2024 20:59
@joaander joaander merged commit a973627 into trunk-patch Jan 22, 2024
38 checks passed
@joaander joaander deleted the cache-existing-chunks branch January 22, 2024 21:05
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