summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-06-04 13:37:51 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-06-04 13:37:51 (GMT)
commitba26e8f2ad29dbefd3078b2f97b7a731ba39db1e (patch)
tree5080a9a458d135c22a394c60f170ff3349121b8d /src
parent8ae371469a5441e54c5df3c6a3372bdf6a66fc6b (diff)
downloadhdf5-ba26e8f2ad29dbefd3078b2f97b7a731ba39db1e.zip
hdf5-ba26e8f2ad29dbefd3078b2f97b7a731ba39db1e.tar.gz
hdf5-ba26e8f2ad29dbefd3078b2f97b7a731ba39db1e.tar.bz2
[svn-r5521] Purpose:
Code improvement Description: The metadata aggregation code in the library was not terribly smart about extending contiguous regions of metadata in the file and would not extend them as far as possible. This causes space in the file to be wasted, also. Solution: Be smarter about extending the space used in the file for metadata by checking whether new metadata blocks allocated in the file are at the end of the current metadata aggregation region and append them to the metadata region if so. This has the nice side benefit of reducing the number of bytes we waste in the file and reducing the size of the file by a small amount in some cases. This reduces the number of I/O operations which hit the disk for my test program from 53 to 19 (i.e. from 393 to 19, overall). Platforms tested: Solaris 2.7 (arabica) w/FORTRAN and FreeBSD 4.5 (sleipnir) w/C++
Diffstat (limited to 'src')
-rw-r--r--src/H5FD.c47
1 files changed, 36 insertions, 11 deletions
diff --git a/src/H5FD.c b/src/H5FD.c
index 30cbbee..03e9194 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -1425,22 +1425,47 @@ H5FD_alloc(H5FD_t *file, H5FD_mem_t type, hsize_t size)
if((file->feature_flags&H5FD_FEAT_AGGREGATE_METADATA) && type!=H5FD_MEM_DRAW) {
/* Check if the space requested is larger than the space left in the block */
if(size>file->cur_meta_block_size) {
+ haddr_t new_meta; /* Address for new metadata */
+
/* Check if the block asked for is too large for a metadata block */
if(size>=file->def_meta_block_size) {
- /* Allocate just enough room for this new block the regular way */
- ret_value=H5FD_real_alloc(file,type,size);
+ /* Allocate more room for this new block the regular way */
+ new_meta=H5FD_real_alloc(file,type,size);
+
+ /* Check if the new metadata is at the end of the current metadata block */
+ if(file->eoma+file->cur_meta_block_size==new_meta) {
+ /* Treat the allocation request as if the current metadata block
+ * grew by the amount allocated and just update the eoma
+ * address. Don't bother updating the cur_meta_block_size
+ * since it will just grow and shrink by the same amount.
+ */
+ ret_value=file->eoma;
+ file->eoma+=size;
+ } /* end if */
+ else {
+ /* Use the new metadata block for the space allocated */
+ ret_value=new_meta;
+ } /* end else */
} /* end if */
else {
- /*
- * Instead of just dropping the remainder of the block on the
- * floor and leaving the space in the file unused, we should
- * return this small piece of unused space to the free list
- * management. - QAK
- */
-
/* Allocate another metadata block */
- file->eoma=H5FD_real_alloc(file,H5FD_MEM_DEFAULT,file->def_meta_block_size);
- file->cur_meta_block_size=file->def_meta_block_size;
+ new_meta=H5FD_real_alloc(file,H5FD_MEM_DEFAULT,file->def_meta_block_size);
+
+ /* Check if the new metadata is at the end of the current metadata block */
+ if(file->eoma+file->cur_meta_block_size==new_meta) {
+ file->cur_meta_block_size+=file->def_meta_block_size;
+ } /* end if */
+ else {
+ /*
+ * Instead of just dropping the remainder of the block on the
+ * floor and leaving the space in the file unused, we should
+ * return this small piece of unused space to the free list
+ * management. - QAK
+ */
+ file->eoma=new_meta;
+ file->cur_meta_block_size=file->def_meta_block_size;
+ } /* end else */
+
/* Allocate space out of the metadata block */
ret_value=file->eoma;