diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2002-06-04 17:26:39 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2002-06-04 17:26:39 (GMT) |
commit | d60f9461ca50bc45106debc95a0c6414711a942c (patch) | |
tree | 81e696f0f45b68fa7db5f0977d3d52b037f3dd67 /src | |
parent | fd12b5d47c211f0873ba8682688244028af5c48f (diff) | |
download | hdf5-d60f9461ca50bc45106debc95a0c6414711a942c.zip hdf5-d60f9461ca50bc45106debc95a0c6414711a942c.tar.gz hdf5-d60f9461ca50bc45106debc95a0c6414711a942c.tar.bz2 |
[svn-r5528] 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')
-rw-r--r-- | src/H5FD.c | 40 |
1 files changed, 36 insertions, 4 deletions
@@ -37,6 +37,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 @@ -2207,15 +2211,29 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_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) { + hsize_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; @@ -2470,15 +2488,29 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t s } /* 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) { + hsize_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; |