summaryrefslogtreecommitdiffstats
path: root/src/H5FD.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-06-04 17:27:13 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-06-04 17:27:13 (GMT)
commit56e4d8fb0cbbcd1b1036b361758ff84a40d2cb01 (patch)
tree427f40da5ab0118e854916e2af2cc3125508139a /src/H5FD.c
parent945e417faa9c5407bc23d80f6d089b209a051237 (diff)
downloadhdf5-56e4d8fb0cbbcd1b1036b361758ff84a40d2cb01.zip
hdf5-56e4d8fb0cbbcd1b1036b361758ff84a40d2cb01.tar.gz
hdf5-56e4d8fb0cbbcd1b1036b361758ff84a40d2cb01.tar.bz2
[svn-r5529] Purpose:
Code improvement Description: Now that the metadata accumulator is working correctly, the buffer size tends to get rather large and stay there. Solution: Put a throttle on the accumulator buffer to reduce its size back down when it isn't needed. Platforms tested: Solaris 2.7 (arabica) w/FORTRAN & FreeBSD 4.5 (sleipnir) w/C++
Diffstat (limited to 'src/H5FD.c')
-rw-r--r--src/H5FD.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/src/H5FD.c b/src/H5FD.c
index 03e9194..55c8847 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -38,6 +38,10 @@ static haddr_t H5FD_real_alloc(H5FD_t *file, H5FD_mem_t type, hsize_t size);
/* Declare a PQ free list to manage the metadata accumulator buffer */
H5FL_BLK_DEFINE_STATIC(meta_accum);
+/* Local macro definitions */
+#define H5FD_ACCUM_THROTTLE 8
+#define H5FD_ACCUM_THRESHOLD 2048
+
/* Static local variables */
/* Global count of the number of H5FD_t's handed out. This is used as a
@@ -2230,15 +2234,29 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz
} /* end if */
/* Cache the new piece of metadata */
- /* Check if we need to reallocate the buffer */
+ /* Check if we need to resize the buffer */
if(size>file->accum_buf_size) {
- /* Reallocate the metadata accumulator buffer */
+ /* Grow the metadata accumulator buffer */
if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,size))==NULL)
HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
/* Note the new buffer size */
file->accum_buf_size=size;
} /* end if */
+ else {
+ /* Check if we should shrink the accumulator buffer */
+ if(size<(file->accum_buf_size/H5FD_ACCUM_THROTTLE) &&
+ file->accum_buf_size>H5FD_ACCUM_THRESHOLD) {
+ size_t new_size=(file->accum_buf_size/H5FD_ACCUM_THROTTLE); /* New size of accumulator buffer */
+
+ /* Shrink the accumulator buffer */
+ if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,new_size))==NULL)
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
+
+ /* Note the new buffer size */
+ file->accum_buf_size=new_size;
+ } /* end if */
+ } /* end else */
/* Update accumulator information */
file->accum_loc=addr;
@@ -2484,15 +2502,29 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t si
} /* end if */
/* Cache the new piece of metadata */
- /* Check if we need to reallocate the buffer */
+ /* Check if we need to resize the buffer */
if(size>file->accum_buf_size) {
- /* Reallocate the metadata accumulator buffer */
+ /* Grow the metadata accumulator buffer */
if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,size))==NULL)
HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
/* Note the new buffer size */
file->accum_buf_size=size;
} /* end if */
+ else {
+ /* Check if we should shrink the accumulator buffer */
+ if(size<(file->accum_buf_size/H5FD_ACCUM_THROTTLE) &&
+ file->accum_buf_size>H5FD_ACCUM_THRESHOLD) {
+ size_t new_size=(file->accum_buf_size/H5FD_ACCUM_THROTTLE); /* New size of accumulator buffer */
+
+ /* Shrink the accumulator buffer */
+ if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,new_size))==NULL)
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
+
+ /* Note the new buffer size */
+ file->accum_buf_size=new_size;
+ } /* end if */
+ } /* end else */
/* Update the metadata accumulator information */
file->accum_loc=addr;