summaryrefslogtreecommitdiffstats
path: root/src/H5Gstab.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-01-09 17:20:03 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-01-09 17:20:03 (GMT)
commit9a433b99a56dc575f1c0b11f95b744de61859dbb (patch)
treed8c766537cb9adc364c902bd45477d97f67a4a9f /src/H5Gstab.c
parent7fd449cb7987772a2881a5ced2ae7ad5231f1fa3 (diff)
downloadhdf5-9a433b99a56dc575f1c0b11f95b744de61859dbb.zip
hdf5-9a433b99a56dc575f1c0b11f95b744de61859dbb.tar.gz
hdf5-9a433b99a56dc575f1c0b11f95b744de61859dbb.tar.bz2
[svn-r6252] Purpose:
Lots of performance improvements & a couple new internal API interfaces. Description: Performance Improvements: - Cached file offset & length sizes in shared file struct, to avoid constantly looking them up in the FCPL. - Generic property improvements: - Added "revision" number to generic property classes to speed up comparisons. - Changed method of storing properties from using a hash-table to the TBBT routines in the library. - Share the propery names between classes and the lists derived from them. - Removed redundant 'def_value' buffer from each property. - Switching code to use a "copy on write" strategy for properties in each list, where the properties in each list are shared with the properties in the class, until a property's value is changed in a list. - Fixed error in layout code which was allocating too many buffers. - Redefined public macros of the form (H5open()/H5check, <variable>) internally to only be (<variable>), avoiding innumerable useless calls to H5open() and H5check_version(). - Reuse already zeroed buffers in H5F_contig_fill instead of constantly re-zeroing them. - Don't write fill values if writing entire dataset. - Use gettimeofday() system call instead of time() system when checking the modification time of a dataset. - Added reference counted string API and use it for tracking the names of objects opening in a file (for the ID->name code). - Removed redundant H5P_get() calls in B-tree routines. - Redefine H5T datatype macros internally to the library, to avoid calling H5check redundantly. - Keep dataspace information for dataset locally instead of reading from disk each time. Added new module to track open objects in a file, to allow this (which will be useful eventually for some FPH5 metadata caching issues). - Remove H5AC_find macro which was inlining metadata cache lookups, and call function instead. - Remove redundant memset() calls from H5G_namei() routine. - Remove redundant checking of object type when locating objects in metadata cache and rely on the address only. - Create default dataset object to use when default dataset creation property list is used to create datasets, bypassing querying for all the property list values. - Use default I/O vector size when performing raw data with the default dataset transfer property list, instead of querying for I/O vector size. - Remove H5P_DEFAULT internally to the library, replacing it with more specific default property list based on the type of property list needed. - Remove redundant memset() calls in object header message (H5O*) routines. - Remove redunant memset() calls in data I/O routines. - Split free-list allocation routines into malloc() and calloc()- like routines, instead of one combined routine. - Remove lots of indirection in H5O*() routines. - Simplify metadata cache entry comparison routine (used when flushing entire cache out). - Only enable metadata cache statistics when H5AC_DEBUG is turned on, instead of always tracking them. - Simplify address comparison macro (H5F_addr_eq). - Remove redundant metadata cache entry protections during dataset creation by protecting the object header once and making all the modifications necessary for the dataset creation before unprotecting it. - Reduce # of "number of element in extent" computations performed by computing and storing the value during dataspace creation. - Simplify checking for group location's file information, when file has not been involving in file-mounting operations. - Use binary encoding for modification time, instead of ASCII. - Hoist H5HL_peek calls (to get information in a local heap) out of loops in many group routine. - Use static variable for iterators of selections, instead of dynamically allocation them each time. - Lookup & insert new entries in one step, avoiding traversing group's B-tree twice. - Fixed memory leak in H5Gget_objname_idx() routine (tangential to performance improvements, but fixed along the way). - Use free-list for reference counted strings. - Don't bother copying object names into cached group entries, since they are re-created when an object is opened. The benchmark I used to measure these results created several thousand small (2K) datasets in a file and wrote out the data for them. This is Elena's "regular.c" benchmark. These changes resulted in approximately ~4.3x speedup of the development branch when compared to the previous code in the development branch and ~1.4x speedup compared to the release branch. Additionally, these changes reduce the total memory used (code and data) by the development branch by ~800KB, bringing the development branch back into the same ballpark as the release branch. I'll send out a more detailed description of the benchmark results as a followup note. New internal API routines: Added "reference counted strings" API for tracking strings that get used by multiple owners without duplicating the strings. Added "ternary search tree" API for text->object mappings. Platforms tested: Tested h5committest {arabica (fortran), eirene (fortran, C++) modi4 (parallel, fortran)} Other platforms/configurations tested? FreeBSD 4.7 (sleipnir) serial & parallel Solaris 2.6 (baldric) serial
Diffstat (limited to 'src/H5Gstab.c')
-rw-r--r--src/H5Gstab.c76
1 files changed, 53 insertions, 23 deletions
diff --git a/src/H5Gstab.c b/src/H5Gstab.c
index 12d0ccb..e5e2535 100644
--- a/src/H5Gstab.c
+++ b/src/H5Gstab.c
@@ -12,6 +12,7 @@
#include "H5private.h"
#include "H5Eprivate.h"
#include "H5Fpkg.h" /*file access */
+#include "H5FLprivate.h" /*Free Lists */
#include "H5Gpkg.h"
#include "H5HLprivate.h"
#include "H5MMprivate.h"
@@ -21,6 +22,9 @@
static int interface_initialize_g = 0;
#define INTERFACE_INIT NULL
+/* Declare extern the PQ free list for the wrapped strings */
+H5FL_BLK_EXTERN(str_buf);
+
/* Private prototypes */
static herr_t H5G_insert_name(H5G_entry_t *loc, H5G_entry_t *obj,
const char *name);
@@ -95,7 +99,7 @@ H5G_stab_create(H5F_t *f, size_t init, H5G_entry_t *self/*out*/)
* Insert the symbol table message into the object header and the symbol
* table entry.
*/
- if (H5O_modify(self, H5O_STAB, H5O_NEW_MESG, H5O_FLAG_CONSTANT, &stab)<0) {
+ if (H5O_modify(self, H5O_STAB, H5O_NEW_MESG, H5O_FLAG_CONSTANT, 1, &stab)<0) {
H5O_close(self);
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message");
}
@@ -160,8 +164,8 @@ H5G_stab_find(H5G_entry_t *grp_ent, const char *name,
/* change OBJ_ENT only if found */
else {
if (obj_ent) {
- /* do a deep copy */
- if (H5G_ent_copy(obj_ent, &(udata.ent),H5G_COPY_DEEP)<0)
+ /* do a NULL copy, since the obj_ent name will be constructed in H5G_insert_name() */
+ if (H5G_ent_copy(obj_ent, &(udata.ent),H5G_COPY_NULL)<0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to copy entry");
/* insert the name into the symbol entry OBJ_ENT */
@@ -224,7 +228,7 @@ H5G_stab_insert(H5G_entry_t *grp_ent, const char *name, H5G_entry_t *obj_ent)
udata.operation = H5G_OPER_INSERT;
udata.name = name;
udata.heap_addr = stab.heap_addr;
- H5G_ent_copy(&(udata.ent),obj_ent,H5G_COPY_SHALLOW); /* Shallow copy here, deep copy happens in H5G_node_insert() callback() */
+ H5G_ent_copy(&(udata.ent),obj_ent,H5G_COPY_NULL); /* NULL copy here, no copies happens in H5G_node_insert() callback() */
/* insert */
if (H5B_insert(grp_ent->file, H5B_SNODE, stab.btree_addr, split_ratios, &udata) < 0)
@@ -301,6 +305,8 @@ done:
static herr_t
H5G_insert_name(H5G_entry_t *loc, H5G_entry_t *obj, const char *name)
{
+ char *new_user_path; /* Pointer to new user path */
+ char *new_canon_path; /* Pointer to new canonical path */
size_t name_len; /* Length of name to append */
size_t user_path_len; /* Length of location's user path name */
size_t canon_path_len; /* Length of location's canonical path name */
@@ -313,55 +319,79 @@ H5G_insert_name(H5G_entry_t *loc, H5G_entry_t *obj, const char *name)
assert(name);
/* Only attempt to build a new name if the location's name exists */
- if(loc->canon_path) {
+ if(loc->canon_path_r) {
+ const char *loc_user_path; /* Pointer to raw string for user path */
+ const char *loc_canon_path; /* Pointer to raw string for canonical path */
/* Reset the object's previous names, if they exist */
- H5MM_xfree(obj->user_path);
- H5MM_xfree(obj->canon_path);
+ if(obj->user_path_r) {
+ H5RS_decr(obj->user_path_r);
+ obj->user_path_r=NULL;
+ } /* end if */
+ if(obj->canon_path_r) {
+ H5RS_decr(obj->canon_path_r);
+ obj->canon_path_r=NULL;
+ } /* end if */
obj->user_path_hidden=0;
/* Get the length of the strings involved */
- user_path_len = HDstrlen(loc->user_path);
- canon_path_len = HDstrlen(loc->canon_path);
+ user_path_len = H5RS_len(loc->user_path_r);
+ canon_path_len = H5RS_len(loc->canon_path_r);
name_len = HDstrlen(name);
/* Modify the object's user path */
+ /* Get the raw string for the user path */
+ loc_user_path=H5RS_GET_STR(loc->user_path_r);
+ assert(loc_user_path);
+
/* The location's user path already ends in a '/' separator */
- if ('/'==loc->user_path[user_path_len-1]) {
- if (NULL==(obj->user_path = H5MM_malloc (user_path_len+name_len+1)))
+ if ('/'==loc_user_path[user_path_len-1]) {
+ if (NULL==(new_user_path = H5FL_BLK_MALLOC(str_buf,user_path_len+name_len+1)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
- HDstrcpy(obj->user_path, loc->user_path);
+ HDstrcpy(new_user_path, loc_user_path);
} /* end if */
/* The location's user path needs a separator */
else {
- if (NULL==(obj->user_path = H5MM_malloc (user_path_len+1+name_len+1)))
+ if (NULL==(new_user_path = H5FL_BLK_MALLOC(str_buf,user_path_len+1+name_len+1)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
- HDstrcpy(obj->user_path, loc->user_path);
- HDstrcat(obj->user_path, "/");
+ HDstrcpy(new_user_path, loc_user_path);
+ HDstrcat(new_user_path, "/");
} /* end else */
/* Append the component's name */
- HDstrcat(obj->user_path, name);
+ HDstrcat(new_user_path, name);
+
+ /* Give ownership of the user path to the entry */
+ obj->user_path_r=H5RS_own(new_user_path);
+ assert(obj->user_path_r);
/* Modify the object's canonical path */
+ /* Get the raw string for the canonical path */
+ loc_canon_path=H5RS_GET_STR(loc->canon_path_r);
+ assert(loc_canon_path);
+
/* The location's canonical path already ends in a '/' separator */
- if ('/'==loc->canon_path[canon_path_len-1]) {
- if (NULL==(obj->canon_path = H5MM_malloc (canon_path_len+name_len+1)))
+ if ('/'==loc_canon_path[canon_path_len-1]) {
+ if (NULL==(new_canon_path = H5FL_BLK_MALLOC(str_buf,canon_path_len+name_len+1)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
- HDstrcpy(obj->canon_path, loc->canon_path);
+ HDstrcpy(new_canon_path, loc_canon_path);
} /* end if */
/* The location's canonical path needs a separator */
else {
- if (NULL==(obj->canon_path = H5MM_malloc (canon_path_len+1+name_len+1)))
+ if (NULL==(new_canon_path = H5FL_BLK_MALLOC(str_buf,canon_path_len+1+name_len+1)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
- HDstrcpy(obj->canon_path, loc->canon_path);
- HDstrcat(obj->canon_path, "/");
+ HDstrcpy(new_canon_path, loc_canon_path);
+ HDstrcat(new_canon_path, "/");
} /* end else */
/* Append the component's name */
- HDstrcat(obj->canon_path, name);
+ HDstrcat(new_canon_path, name);
+
+ /* Give ownership of the canonical path to the entry */
+ obj->canon_path_r=H5RS_own(new_canon_path);
+ assert(obj->canon_path_r);
} /* end if */
done: