[hdf-compass] 70/295: Adjust HDF5 cache settings

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Sun May 8 10:35:27 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/master
in repository hdf-compass.

commit 34a20df5de689642c651b1f34cc3157615daab63
Author: Andrew Collette <andrew.collette at gmail.com>
Date:   Tue May 5 19:29:57 2015 -0600

    Adjust HDF5 cache settings
---
 hdf5_model/__init__.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/hdf5_model/__init__.py b/hdf5_model/__init__.py
index ef20a17..2a11c2c 100644
--- a/hdf5_model/__init__.py
+++ b/hdf5_model/__init__.py
@@ -45,6 +45,9 @@ class HDF5Store(compass_model.Store):
 
     file_extensions = {'HDF5 File': ['*.hdf5', '*.h5']}
     
+    CACHE_NCHUNKS = 100         # Cache at most this many chunks per dataset
+    CACHE_NBYTES = int(25e6)    # Cache at most this many bytes per dataset
+    
     def __contains__(self, key):
         return key in self.f
 
@@ -84,8 +87,13 @@ class HDF5Store(compass_model.Store):
             raise ValueError(url)
         self._url = url
         path = url.replace('file://','')
-        self.f = h5py.File(path, 'r')
-
+        
+        fapl = h5py.h5p.create(h5py.h5p.FILE_ACCESS)
+        # First argument is ignored by HDF5.
+        # Last argument adjusts the preemption policy (0.0 = simple LRU)
+        fapl.set_cache(0, self.CACHE_NCHUNKS, self.CACHE_NBYTES, 0.0)
+        fid = h5py.h5f.open(path, h5py.h5f.ACC_RDONLY, fapl=fapl)
+        self.f = h5py.File(fid)
 
     def close(self):
         self.f.close()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/hdf-compass.git



More information about the debian-science-commits mailing list