-
Notifications
You must be signed in to change notification settings - Fork 859
Release netCDF memory-map pages after each frame #5463
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,9 +22,11 @@ | |
| # | ||
| import MDAnalysis as mda | ||
| import numpy as np | ||
| import mmap | ||
| import sys | ||
|
|
||
| from scipy.io import netcdf_file | ||
| from types import SimpleNamespace | ||
|
|
||
| import pytest | ||
| from numpy.testing import assert_equal, assert_almost_equal | ||
|
|
@@ -148,6 +150,22 @@ class TestNCDFReaderTZ2(_NCDFReaderTest, RefTZ2): | |
| pass | ||
|
|
||
|
|
||
| @pytest.mark.skipif( | ||
| not hasattr(mmap, "MADV_DONTNEED"), reason="no MADV_DONTNEED" | ||
| ) | ||
| def test_mmap_pages_dropped(monkeypatch): | ||
| """Reading a frame releases its pages of the memory map.""" | ||
| universe = mda.Universe(PRM_NCBOX, TRJ_NCBOX, mmap=True) | ||
| advice = [] | ||
| monkeypatch.setattr( | ||
| universe.trajectory.trjfile, | ||
| "_mm", | ||
| SimpleNamespace(madvise=advice.append), | ||
| ) | ||
| universe.trajectory[1] | ||
| assert advice == [mmap.MADV_DONTNEED] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test is a bit convoluted with Also, am I understanding correctly that on this branch something like https://github.com/pythonprofilers/memory_profiler should show a constant level of physical memory consumption, while it should increase linearly when reading in/iterating over a trajecotry of the appropriate type on the We could probably capture that with https://asv.readthedocs.io/en/stable/writing_benchmarks.html#peak-memory as well, assuming you're saying that physical memory is being used excessively on |
||
|
|
||
|
|
||
| class TestNCDFReader2(object): | ||
| """NCDF Trajectory with positions and forces. | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I don't think it is necessary to add a
versionchangeddirective for a bug fix--mostly just appropriate for user-facing behavior changes, otherwise we may have way too many such directives.