summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@lbl.gov>2020-06-11 17:02:19 (GMT)
committerQuincey Koziol <koziol@lbl.gov>2020-06-11 17:02:19 (GMT)
commit22bc73c11121cc3d7914c23ceffde4655b01f038 (patch)
tree4b61e4b62492c945ca9bfcc8c4bc3b03774ad15a
parent24748a738ed80930d67fbab95c91e1c07971103b (diff)
parent38886e95b2f8e6bf84db51ea4f7569295268cff1 (diff)
downloadhdf5-22bc73c11121cc3d7914c23ceffde4655b01f038.zip
hdf5-22bc73c11121cc3d7914c23ceffde4655b01f038.tar.gz
hdf5-22bc73c11121cc3d7914c23ceffde4655b01f038.tar.bz2
Merge pull request #2642 in HDFFV/hdf5 from hdf5_1_12_cache_last_id_info to hdf5_1_12
* commit '38886e95b2f8e6bf84db51ea4f7569295268cff1': Update release notes for last ID caching. Remember the info for the last ID looked up for a given ID type.
-rw-r--r--release_docs/RELEASE.txt5
-rw-r--r--src/H5I.c24
2 files changed, 27 insertions, 2 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index 69a1ce7..c2d24c0 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -109,6 +109,11 @@ Bug Fixes since HDF5-1.12.0 release
==================================
Library
-------
+ - Cache last ID looked up for an ID type (dataset, datatype, file, etc),
+ improving performance when accessing the same ID repeatedly.
+
+ (QAK - 2020/06/11)
+
- Streamline I/O to a single element, improving performance for record
appends to chunked datasets.
diff --git a/src/H5I.c b/src/H5I.c
index 07cf7b2..8ae808d 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -67,6 +67,7 @@ typedef struct {
unsigned init_count; /* # of times this type has been initialized*/
uint64_t id_count; /* Current number of IDs held */
uint64_t nextid; /* ID to use for the next atom */
+ H5I_id_info_t *last_info; /* Info for most recent ID looked up */
H5SL_t *ids; /* Pointer to skip list that stores IDs */
} H5I_id_type_t;
@@ -317,6 +318,7 @@ H5I_register_type(const H5I_class_t *cls)
type_ptr->cls = cls;
type_ptr->id_count = 0;
type_ptr->nextid = cls->reserved;
+ type_ptr->last_info = NULL;
if(NULL == (type_ptr->ids = H5SL_create(H5SL_TYPE_HID, NULL)))
HGOTO_ERROR(H5E_ATOM, H5E_CANTCREATE, FAIL, "skip list creation failed")
} /* end if */
@@ -806,6 +808,9 @@ H5I_register(H5I_type_t type, const void *object, hbool_t app_ref)
/* Sanity check for the 'nextid' getting too large and wrapping around */
HDassert(type_ptr->nextid <= ID_MASK);
+ /* Set the most recent ID to this object */
+ type_ptr->last_info = id_ptr;
+
/* Set return value */
ret_value = new_id;
@@ -877,6 +882,9 @@ H5I_register_using_existing_id(H5I_type_t type, void *object, hbool_t app_ref, h
HGOTO_ERROR(H5E_ATOM, H5E_CANTINSERT, FAIL, "can't insert ID node into skip list")
type_ptr->id_count++;
+ /* Set the most recent ID to this object */
+ type_ptr->last_info = id_ptr;
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_register_using_existing_id() */
@@ -1235,6 +1243,10 @@ H5I__remove_common(H5I_id_type_t *type_ptr, hid_t id)
if(NULL == (curr_id = (H5I_id_info_t *)H5SL_remove(type_ptr->ids, &id)))
HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, NULL, "can't remove ID node from skip list")
+ /* Check if this ID was the last one accessed */
+ if(type_ptr->last_info == curr_id)
+ type_ptr->last_info = NULL;
+
ret_value = (void *)curr_id->obj_ptr; /* (Casting away const OK -QAK) */
curr_id = H5FL_FREE(H5I_id_info_t, curr_id);
@@ -2184,8 +2196,16 @@ H5I__find_id(hid_t id)
if(!type_ptr || type_ptr->init_count <= 0)
HGOTO_DONE(NULL)
- /* Locate the ID node for the ID */
- ret_value = (H5I_id_info_t *)H5SL_search(type_ptr->ids, &id);
+ /* Check for same ID as we have looked up last time */
+ if(type_ptr->last_info && type_ptr->last_info->id == id)
+ ret_value = type_ptr->last_info;
+ else {
+ /* Locate the ID node for the ID */
+ ret_value = (H5I_id_info_t *)H5SL_search(type_ptr->ids, &id);
+
+ /* Remember this ID */
+ type_ptr->last_info = ret_value;
+ } /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)