Skip to content

Commit a76d33c

Browse files
committed
Add threshold for r-tree usage
1 parent e8f23b0 commit a76d33c

File tree

7 files changed

+219
-64
lines changed

7 files changed

+219
-64
lines changed

doxygen/examples/tables/propertyLists.dox

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ encoding for object names.</td>
618618
</tr>
619619
<tr>
620620
<td>#H5Pset_dset_use_spatial_tree/#H5Pget_dset_use_spatial_tree</td>
621-
<td>Sets/gets the flag to use spatial trees when searching VDS mappings</td>
621+
<td>Sets/gets the flag to use spatial trees when searching many VDS mappings</td>
622622
</tr>
623623
</table>
624624
//! [dapl_table]

fortran/src/H5Pff.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4404,7 +4404,7 @@ END SUBROUTINE h5pget_dset_use_spatial_tree_f
44044404
!! \ingroup FH5P
44054405
!!
44064406
!! \brief Sets the value of the "use spatial tree" flag which enables spatial tree
4407-
!! construction and usage for VDS mapping searches.
4407+
!! construction and usage for large VDS mapping searches.
44084408
!!
44094409
!! \param dapl_id Target dataset access property list identifier.
44104410
!! \param use_tree Value of the setting.

release_docs/CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,10 @@ HDF5 release, platforms tested, and known problems in this release.
408408
to iterate through every source dataset's dataspace and check for an intersection
409409
with the user-selected region for a read/write in the virtual dataset.
410410
411-
Virtual datasets now use an r-tree (defined in H5RT.c) to perform a spatial search.
412-
This allows the dataspaces that intersect the user-selection to be computed with,
413-
in most cases, vastly fewer costly intersection checks, improving the speed of VDS
414-
read/write operations.
411+
Virtual datasets with many mappings now use an r-tree (defined in H5RT.c) to
412+
perform a spatial search. This allows the dataspaces that intersect the
413+
user-selection to be computed with, in most cases, much fewer intersection checks,
414+
improving the speed of VDS read/write operations.
415415
416416
Virtual datasets will use the r-tree by default, since the majority of use cases,
417417
should see improvements from use of the tree. However, because some workflows may

src/H5Dprivate.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@
125125
/* Default virtual dataset list size */
126126
#define H5D_VIRTUAL_DEF_LIST_SIZE 8
127127

128+
/* Threshold for use of a tree for VDS mappings */
129+
#define H5D_VIRTUAL_TREE_THRESHOLD 50
130+
128131
#ifdef H5D_MODULE
129132
#define H5D_OBJ_ID(D) (((H5D_obj_create_t *)(D))->dcpl_id)
130133
#else /* H5D_MODULE */

src/H5Dvirtual.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3088,7 +3088,7 @@ H5D__virtual_pre_io(H5D_dset_io_info_t *dset_info, H5O_storage_virtual_t *storag
30883088
if (H5P_get(dapl_plist, H5D_ACS_USE_TREE_NAME, &tree_enabled) < 0)
30893089
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get virtual use tree flag");
30903090

3091-
if (tree_enabled && !storage->tree) {
3091+
if (tree_enabled && !storage->tree && storage->list_nused >= H5D_VIRTUAL_TREE_THRESHOLD) {
30923092
int rank = 0;
30933093
assert(!storage->is_in_tree);
30943094
/* Get the rank of the dataset */

src/H5RT.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ H5RT__bulk_load(H5RT_node_t *node, int rank, H5RT_leaf_t *leaves, size_t count,
335335
assert(child_leaf_start + leaves_left <= leaves + count);
336336

337337
/* Allocate this child node */
338-
if (NULL == (node->children.nodes[i] = H5FL_CALLOC(H5RT_node_t)))
338+
if (NULL == (node->children.nodes[i] = H5FL_MALLOC(H5RT_node_t)))
339339
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "failed to allocate memory for R-tree node");
340340

341341
child_leaf_count = (leaves_left < slab_size) ? leaves_left : slab_size;
@@ -386,8 +386,7 @@ H5RT_create(int rank, H5RT_leaf_t *leaves, size_t count)
386386
if (count == 0)
387387
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "r-tree must have at least one leaf");
388388

389-
/* TBD: May replace with malloc for optimization */
390-
if (NULL == (rtree = H5FL_CALLOC(H5RT_t)))
389+
if (NULL == (rtree = H5FL_MALLOC(H5RT_t)))
391390
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "failed to allocate memory for R-tree");
392391

393392
rtree->rank = rank;
@@ -445,7 +444,7 @@ H5RT__search_recurse(H5RT_node_t *node, int rank, hsize_t min[], hsize_t max[],
445444

446445
if (H5RT__leaves_intersect(rank, min, max, curr_min, curr_max)) {
447446
/* We found an intersecting leaf, create a result structure for it */
448-
if (NULL == (new_result = H5FL_CALLOC(H5RT_result_t)))
447+
if (NULL == (new_result = H5FL_MALLOC(H5RT_result_t)))
449448
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "failed to allocate result structure");
450449

451450
new_result->leaf = curr_leaf;

0 commit comments

Comments
 (0)