diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2004-07-07 21:25:33 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2004-07-07 21:25:33 (GMT) |
commit | 8d7e8124f1d90afae3262cf8742e2b90cf96251b (patch) | |
tree | 772318ce46046065aa2d2590c96c73218a7f28bd /src/H5Distore.c | |
parent | 2afbcb2f0e536dfdd00c405278154ea4464d866b (diff) | |
download | hdf5-8d7e8124f1d90afae3262cf8742e2b90cf96251b.zip hdf5-8d7e8124f1d90afae3262cf8742e2b90cf96251b.tar.gz hdf5-8d7e8124f1d90afae3262cf8742e2b90cf96251b.tar.bz2 |
[svn-r8824] Purpose:
Code optimization
Description:
Since the raw B-tree nodes are the same size and only used when reading in
or writing out a B-tree node, move raw B-tree node buffer from being per node
to a single node that is shared among all B-tree nodes of a particular tree,
freeing up a lot of space and eliminating lots of memory copies, etc.
Platforms tested:
Solaris 2.7 (arabica)
FreeBSD 4.10 (sleipnir) w/parallel
Too minor to require h5committest
Diffstat (limited to 'src/H5Distore.c')
-rw-r--r-- | src/H5Distore.c | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/src/H5Distore.c b/src/H5Distore.c index a3b2f29..6bfdf40 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -165,6 +165,7 @@ static int H5D_istore_prune_extent(H5F_t *f, hid_t dxpl_id, void *_lt_key, haddr /* B-tree callbacks */ static size_t H5D_istore_sizeof_rkey(H5F_t *f, const void *_udata); +static void *H5D_istore_get_page(H5F_t *f, const void *_udata); static herr_t H5D_istore_new_node(H5F_t *f, hid_t dxpl_id, H5B_ins_t, void *_lt_key, void *_udata, void *_rt_key, haddr_t *addr_p /*out*/); @@ -195,6 +196,7 @@ H5B_class_t H5B_ISTORE[1] = {{ H5B_ISTORE_ID, /*id */ sizeof(H5D_istore_key_t), /*sizeof_nkey */ H5D_istore_sizeof_rkey, /*get_sizeof_rkey */ + H5D_istore_get_page, /*get_page */ H5D_istore_new_node, /*new */ H5D_istore_cmp2, /*cmp2 */ H5D_istore_cmp3, /*cmp3 */ @@ -217,6 +219,9 @@ H5FL_SEQ_DEFINE_STATIC(H5D_rdcc_ent_ptr_t); /* Declare a free list to manage the chunk sequence information */ H5FL_BLK_DEFINE_STATIC(chunk); +/* Declare a free list to manage the raw page information */ +H5FL_BLK_DEFINE_STATIC(chunk_page); + /*------------------------------------------------------------------------- * Function: H5D_istore_sizeof_rkey @@ -257,6 +262,37 @@ H5D_istore_sizeof_rkey(H5F_t UNUSED *f, const void *_udata) /*------------------------------------------------------------------------- + * Function: H5D_istore_get_page + * + * Purpose: Returns the raw data page for the specified UDATA. + * + * Return: Success: Pointer to the raw B-tree page for this dataset + * + * Failure: Can't fail + * + * Programmer: Quincey Koziol + * Monday, July 5, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void * +H5D_istore_get_page(H5F_t UNUSED *f, const void *_udata) +{ + const H5D_istore_ud1_t *udata = (const H5D_istore_ud1_t *) _udata; + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_get_page); + + assert(udata); + assert(udata->mesg); + assert(udata->mesg->u.chunk.raw_page); + + FUNC_LEAVE_NOAPI(udata->mesg->u.chunk.raw_page); +} /* end H5D_istore_get_page() */ + + +/*------------------------------------------------------------------------- * Function: H5D_istore_decode_key * * Purpose: Decodes a raw key into a native key for the B-tree @@ -651,7 +687,7 @@ done: */ static H5B_ins_t H5D_istore_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key, - hbool_t UNUSED *lt_key_changed, + hbool_t *lt_key_changed, void *_md_key, void *_udata, void *_rt_key, hbool_t UNUSED *rt_key_changed, haddr_t *new_node_p/*out*/) @@ -866,6 +902,9 @@ H5D_istore_iter_dump (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, hadd herr_t H5D_istore_init (H5F_t *f, H5D_t *dset) { + H5D_istore_ud1_t udata; + size_t sizeof_rkey; /* Single raw key size */ + size_t size; /* Raw B-tree node size */ H5D_rdcc_t *rdcc = &(dset->cache.chunk); herr_t ret_value=SUCCEED; /* Return value */ @@ -880,6 +919,17 @@ H5D_istore_init (H5F_t *f, H5D_t *dset) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } /* end if */ + /* Initialize "user" data for B-tree callbacks, etc. */ + udata.mesg = &dset->layout; + + /* Set up the "global" information for this dataset's chunks */ + sizeof_rkey = H5D_istore_sizeof_rkey(f, &udata); + assert(sizeof_rkey); + size = H5B_nodesize(f, H5B_ISTORE, NULL, sizeof_rkey); + assert(size); + if(NULL==(dset->layout.u.chunk.raw_page=H5FL_BLK_MALLOC(chunk_page,size))) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree page") + done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5D_istore_init() */ @@ -1158,6 +1208,7 @@ H5D_istore_dest (H5F_t *f, hid_t dxpl_id, H5D_t *dset) if (H5D_get_dxpl_cache(dxpl_id,&dxpl_cache)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache") + /* Flush all the cached chunks */ for (ent=rdcc->head; ent; ent=next) { #ifdef H5D_ISTORE_DEBUG HDfputc('c', stderr); @@ -1173,6 +1224,9 @@ H5D_istore_dest (H5F_t *f, hid_t dxpl_id, H5D_t *dset) H5FL_SEQ_FREE (H5D_rdcc_ent_ptr_t,rdcc->slot); HDmemset (rdcc, 0, sizeof(H5D_rdcc_t)); + /* Free the raw B-tree node buffer */ + H5FL_BLK_FREE(chunk_page,dset->layout.u.chunk.raw_page); + done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5D_istore_dest() */ @@ -1927,7 +1981,9 @@ H5D_istore_create(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout /*out */ ) assert(layout->u.chunk.dim[u] > 0); #endif + /* Initialize "user" data for B-tree callbacks, etc. */ udata.mesg = layout; + if (H5B_create(f, dxpl_id, H5B_ISTORE, &udata, &(layout->u.chunk.addr)/*out*/) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "can't create B-tree"); |