diff options
author | John Mainzer <mainzer@hdfgroup.org> | 2007-08-10 04:19:43 (GMT) |
---|---|---|
committer | John Mainzer <mainzer@hdfgroup.org> | 2007-08-10 04:19:43 (GMT) |
commit | b742150e4c2bc115c531bc285a86dc38153594ca (patch) | |
tree | 4ad16a1b21eff750bde4c42a1fdec3db4b13d4d4 /src | |
parent | 85ae38b38024661f932f2af6af717c6d4e20572b (diff) | |
download | hdf5-b742150e4c2bc115c531bc285a86dc38153594ca.zip hdf5-b742150e4c2bc115c531bc285a86dc38153594ca.tar.gz hdf5-b742150e4c2bc115c531bc285a86dc38153594ca.tar.bz2 |
[svn-r14064] Implemented function allowing the user to cork the metadata cache.
Also implemented associated test code.
Diffstat (limited to 'src')
-rw-r--r-- | src/H5AC.c | 126 | ||||
-rw-r--r-- | src/H5ACprivate.h | 2 | ||||
-rw-r--r-- | src/H5ACpublic.h | 33 | ||||
-rw-r--r-- | src/H5C.c | 140 | ||||
-rw-r--r-- | src/H5Cpkg.h | 14 | ||||
-rw-r--r-- | src/H5Cprivate.h | 10 |
6 files changed, 266 insertions, 59 deletions
@@ -2537,6 +2537,15 @@ done: * JRM - 6/8/06 * Added support for the new trace file related fields. * + * JRM - 7/28/07 + * Added support for the new evictions enabled related fields. + * + * Observe that H5AC_get_cache_auto_resize_config() and + * H5AC_set_cache_auto_resize_config() are becoming generic + * metadata cache configuration routines as they gain + * switches for functions that are only tenuously related + * to auto resize configuration. + * *------------------------------------------------------------------------- */ @@ -2546,6 +2555,7 @@ H5AC_get_cache_auto_resize_config(H5AC_t * cache_ptr, { herr_t result; herr_t ret_value = SUCCEED; /* Return value */ + hbool_t evictions_enabled; H5C_auto_size_ctl_t internal_config; FUNC_ENTER_NOAPI(H5AC_get_cache_auto_resize_config, FAIL) @@ -2581,6 +2591,14 @@ H5AC_get_cache_auto_resize_config(H5AC_t * cache_ptr, "H5C_get_cache_auto_resize_config() failed.") } + result = H5C_get_evictions_enabled((H5C_t *)cache_ptr, &evictions_enabled); + + if ( result < 0 ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "H5C_get_resize_enabled() failed.") + } + if ( internal_config.rpt_fcn == NULL ) { config_ptr->rpt_fcn_enabled = FALSE; @@ -2593,6 +2611,8 @@ H5AC_get_cache_auto_resize_config(H5AC_t * cache_ptr, config_ptr->open_trace_file = FALSE; config_ptr->close_trace_file = FALSE; config_ptr->trace_file_name[0] = '\0'; + config_ptr->set_evictions_enabled = FALSE; + config_ptr->evictions_enabled = evictions_enabled; config_ptr->set_initial_size = internal_config.set_initial_size; config_ptr->initial_size = internal_config.initial_size; config_ptr->min_clean_fraction = internal_config.min_clean_fraction; @@ -2788,6 +2808,15 @@ done: * John Mainzer -- 6/7/06 * Added trace file support. * + * John Mainzer -- 7/28/07 + * Added support for the new evictions enabled related fields. + * + * Observe that H5AC_get_cache_auto_resize_config() and + * H5AC_set_cache_auto_resize_config() are becoming generic + * metadata cache configuration routines as they gain + * switches for functions that are only tenuously related + * to auto resize configuration. + * *------------------------------------------------------------------------- */ @@ -2835,56 +2864,11 @@ H5AC_set_cache_auto_resize_config(H5AC_t * cache_ptr, HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "bad cache_ptr on entry.") } - if ( config_ptr == NULL ) { - - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL config_ptr on entry.") - } - - if ( config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION ) { - - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unknown config version.") - } - - if ( ( config_ptr->rpt_fcn_enabled != TRUE ) && - ( config_ptr->rpt_fcn_enabled != FALSE ) ) { - - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ - "config_ptr->rpt_fcn_enabled must be either TRUE or FALSE.") - } - - if ( ( config_ptr->open_trace_file != TRUE ) && - ( config_ptr->open_trace_file != FALSE ) ) { - - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ - "config_ptr->open_trace_file must be either TRUE or FALSE.") - } - - if ( ( config_ptr->close_trace_file != TRUE ) && - ( config_ptr->close_trace_file != FALSE ) ) { - - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ - "config_ptr->close_trace_file must be either TRUE or FALSE.") - } - - /* don't bother to test trace_file_name unless open_trace_file is TRUE */ - if ( config_ptr->open_trace_file ) { - - /* Can't really test the trace_file_name field without trying to - * open the file, so we will content ourselves with a couple of - * sanity checks on the length of the file name. - */ - name_len = HDstrlen(config_ptr->trace_file_name); - - if ( name_len <= 0 ) { - - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ - "config_ptr->trace_file_name is empty.") + result = H5AC_validate_config(config_ptr); - } else if ( name_len > H5AC__MAX_TRACE_FILE_NAME_LEN ) { + if ( result != SUCCEED ) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ - "config_ptr->trace_file_name too long.") - } + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Bad cache configuration"); } if ( config_ptr->open_trace_file ) { @@ -2957,6 +2941,18 @@ H5AC_set_cache_auto_resize_config(H5AC_t * cache_ptr, "H5C_set_cache_auto_resize_config() failed.") } + if ( config_ptr->set_evictions_enabled ) { + + result = H5C_set_evictions_enabled((H5C_t *)cache_ptr, + config_ptr->evictions_enabled); + + if ( result < 0 ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "H5C_set_evictions_enabled() failed.") + } + } + #ifdef H5_HAVE_PARALLEL if ( cache_ptr->aux_ptr != NULL ) { @@ -2977,13 +2973,15 @@ done: ( trace_file_ptr != NULL ) ) { HDfprintf(trace_file_ptr, - "%s %d %d %d %d \"%s\" %d %d %f %d %d %ld %d %f %f %d %d %d %f %f %d %d %d %d %f %d %d\n", + "%s %d %d %d %d \"%s\" %d %d %d %d %f %d %d %ld %d %f %f %d %d %d %f %f %d %d %d %d %f %d %d\n", "H5AC_set_cache_auto_resize_config", trace_config.version, (int)(trace_config.rpt_fcn_enabled), (int)(trace_config.open_trace_file), (int)(trace_config.close_trace_file), trace_config.trace_file_name, + (int)(trace_config.set_evictions_enabled), + (int)(trace_config.evictions_enabled), (int)(trace_config.set_initial_size), (int)(trace_config.initial_size), trace_config.min_clean_fraction, @@ -3041,6 +3039,13 @@ done: * are applied. * JRM - 5/15/06 * + * - Added code testing the evictions enabled field. At + * present this consists of verifying that if + * set_evictions_enabled is TRUE and evictions_enabled + * is FALSE, then automatic cache resizing in disabled. + * + * JRM - 7/28/07 + * *------------------------------------------------------------------------- */ @@ -3107,6 +3112,29 @@ H5AC_validate_config(H5AC_cache_config_t * config_ptr) } } + if ( ( config_ptr->set_evictions_enabled != TRUE ) && + ( config_ptr->set_evictions_enabled != FALSE ) ) { + + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ + "config_ptr->set_evictions_enabled must be either TRUE or FALSE.") + } + + if ( ( config_ptr->evictions_enabled != TRUE ) && + ( config_ptr->evictions_enabled != FALSE ) ) { + + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ + "config_ptr->evictions_enabled must be either TRUE or FALSE.") + } + + if ( ( config_ptr->set_evictions_enabled == TRUE ) && + ( config_ptr->evictions_enabled == FALSE ) && + ( ( config_ptr->incr_mode != H5C_incr__off ) || + ( config_ptr->incr_mode != H5C_decr__off ) ) ) { + + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ + "Can't disable evictions while auto-resize is enabled.") + } + if ( config_ptr->dirty_bytes_threshold < H5AC__MIN_DIRTY_BYTES_THRESHOLD ) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index 34ca4ef..0d10c88 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -201,6 +201,8 @@ extern hid_t H5AC_ind_dxpl_id; /* hbool_t open_trace_file = */ FALSE, \ /* hbool_t close_trace_file = */ FALSE, \ /* char trace_file_name[] = */ "", \ + /* hbool_t set_evictions_enabled = */ FALSE, \ + /* hbool_t evictions_enabled = */ TRUE, \ /* hbool_t set_initial_size = */ TRUE, \ /* size_t initial_size = */ ( 1 * 1024 * 1024), \ /* double min_clean_fraction = */ 0.5, \ diff --git a/src/H5ACpublic.h b/src/H5ACpublic.h index 362b14f..76e5530 100644 --- a/src/H5ACpublic.h +++ b/src/H5ACpublic.h @@ -107,6 +107,30 @@ extern "C" { * The length of the path must not exceed H5AC__MAX_TRACE_FILE_NAME_LEN * characters. * + * set_evictions_enabled: Boolean flag indicating whether the cache + * evictions_enabled flag is to be set to the value specified + * in the evictions_enabled field below. + * + * evictions_enabled: Boolean field used to either report the current + * evictions enabled status of the cache, or, when + * set_evictions_enabled is TRUE, to set the cache's evictions + * enabled status. + * + * In general, the metadata cache should always be allowed to + * evict entries. However, in some cases it is advantageous to + * disable evictions briefly, and thereby postpone metadata + * writes. However, this must be done with care, as the cache + * can grow quickly. If you do this, re-enable evictions as + * soon as possible and monitor cache size. + * + * At present, evictions can only be disabled if automatic + * cache resizing is also disabled (that is, ( incr_mode == + * H5C_incr__off ) && ( decr_mode == H5C_decr__off )). There + * is no logical reason why this should be so, but it simplifies + * implementation and testing, and I can't think of any reason + * why it would be desireable. If you can think of one, I'll + * revisit the issue. + * * set_initial_size: Boolean flag indicating whether the size of the * initial size of the cache is to be set to the value given in * the initial_size field. If set_initial_size is FALSE, the @@ -160,6 +184,9 @@ extern "C" { * at its maximum size, or if the cache is not already using * all available space. * + * Note that you must set decr_mode to H5C_incr__off if you + * disable metadata cache entry evictions. + * * lower_hr_threshold: Lower hit rate threshold. If the increment mode * (incr_mode) is H5C_incr__threshold and the hit rate drops below the * value supplied in this field in an epoch, increment the cache size by @@ -217,6 +244,9 @@ extern "C" { * over the last epoch exceeds the value provided in the * upper_hr_threshold field. * + * Note that you must set decr_mode to H5C_decr__off if you + * disable metadata cache entry evictions. + * * upper_hr_threshold: Upper hit rate threshold. The use of this field * varies according to the current decr_mode: * @@ -316,6 +346,9 @@ typedef struct H5AC_cache_config_t hbool_t close_trace_file; char trace_file_name[H5AC__MAX_TRACE_FILE_NAME_LEN + 1]; + hbool_t set_evictions_enabled; + hbool_t evictions_enabled; + hbool_t set_initial_size; size_t initial_size; @@ -2835,6 +2835,10 @@ done: * Added initialization for the new is_read_only and * ro_ref_count fields. * + * JRM -- 7/27/07 +* Added initialization for the new evictions_enabled +* field of H5C_t. + * *------------------------------------------------------------------------- */ @@ -2906,6 +2910,8 @@ H5C_create(size_t max_cache_size, cache_ptr->log_flush = log_flush; + cache_ptr->evictions_enabled = TRUE; + cache_ptr->index_len = 0; cache_ptr->index_size = (size_t)0; @@ -4260,6 +4266,52 @@ done: /*------------------------------------------------------------------------- + * Function: H5C_get_evictions_enabled() + * + * Purpose: Copy the current value of cache_ptr->evictions_enabled into + * *evictions_enabled_ptr. + * + * Return: SUCCEED on success, and FAIL on failure. + * + * Programmer: John Mainzer + * 7/27/07 + * + * Modifications: + * + * None. + * + *------------------------------------------------------------------------- + */ + +herr_t +H5C_get_evictions_enabled(H5C_t * cache_ptr, + hbool_t * evictions_enabled_ptr) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5C_get_evictions_enabled, FAIL) + + if ( ( cache_ptr == NULL ) || ( cache_ptr->magic != H5C__H5C_T_MAGIC ) ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") + } + + if ( evictions_enabled_ptr == NULL ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "Bad evictions_enabled_ptr on entry.") + } + + *evictions_enabled_ptr = cache_ptr->evictions_enabled; + +done: + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5C_get_evictions_enabled() */ + + +/*------------------------------------------------------------------------- * Function: H5C_get_trace_file_ptr * * Purpose: Get the trace_file_ptr field from the cache. @@ -4378,6 +4430,10 @@ done: * Added initialization for the new is_read_only and * ro_ref_count fields. * + * JRM -- 8/1/07 + * Added code to disable evictions when the new + * evictions_enabled field is FALSE. + * *------------------------------------------------------------------------- */ @@ -4468,7 +4524,9 @@ H5C_insert_entry(H5F_t * f, H5C__RESET_CACHE_ENTRY_STATS(entry_ptr) - if ((cache_ptr->index_size + entry_ptr->size) > cache_ptr->max_cache_size) { + if ( ( cache_ptr->evictions_enabled ) && + ( (cache_ptr->index_size + entry_ptr->size) > + cache_ptr->max_cache_size ) ) { size_t space_needed; @@ -5545,6 +5603,10 @@ done: * Also added code to allow multiple read only protects * of cache entries. * + * JRM -- 7/27/07 + * Added code supporting the new evictions_enabled fieled + * in H5C_t. + * *------------------------------------------------------------------------- */ @@ -5616,9 +5678,10 @@ H5C_protect(H5F_t * f, entry_ptr = (H5C_cache_entry_t *)thing; - /* try to free up some space if necessary */ - if ( (cache_ptr->index_size + entry_ptr->size) > - cache_ptr->max_cache_size ) { + /* try to free up some space if necessary and if evictions are permitted */ + if ( ( cache_ptr->evictions_enabled ) && + ( (cache_ptr->index_size + entry_ptr->size) > + cache_ptr->max_cache_size ) ) { size_t space_needed; @@ -5754,10 +5817,11 @@ H5C_protect(H5F_t * f, ret_value = thing; - if ( ( cache_ptr->size_decreased ) || - ( ( cache_ptr->resize_enabled ) && - ( cache_ptr->cache_accesses >= - (cache_ptr->resize_ctl).epoch_length ) ) ) { + if ( ( cache_ptr->evictions_enabled ) && + ( ( cache_ptr->size_decreased ) || + ( ( cache_ptr->resize_enabled ) && + ( cache_ptr->cache_accesses >= + (cache_ptr->resize_ctl).epoch_length ) ) ) ) { if ( ! have_write_permitted ) { @@ -6140,6 +6204,66 @@ done: /*------------------------------------------------------------------------- + * Function: H5C_set_evictions_enabled() + * + * Purpose: Set cache_ptr->evictions_enabled to the value of the + * evictions enabled parameter. + * + * Return: SUCCEED on success, and FAIL on failure. + * + * Programmer: John Mainzer + * 7/27/07 + * + * Modifications: + * + * None. + * + *------------------------------------------------------------------------- + */ + +herr_t +H5C_set_evictions_enabled(H5C_t * cache_ptr, + hbool_t evictions_enabled) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5C_set_evictions_enabled, FAIL) + + if ( ( cache_ptr == NULL ) || ( cache_ptr->magic != H5C__H5C_T_MAGIC ) ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") + } + + if ( ( evictions_enabled != TRUE ) && ( evictions_enabled != FALSE ) ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "Bad evictions_enabled on entry.") + } + + /* There is no fundamental reason why we should not permit + * evictions to be disabled while automatic resize is enabled. + * However, I can't think of any good reason why one would + * want to, and allowing it would greatly complicate testing + * the feature. Hence the following: + */ + if ( ( evictions_enabled != TRUE ) && + ( ( cache_ptr->resize_ctl.incr_mode != H5C_incr__off ) || + ( cache_ptr->resize_ctl.decr_mode != H5C_decr__off ) ) ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "Can't disable evictions when auto resize enabled.") + } + + cache_ptr->evictions_enabled = evictions_enabled; + +done: + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5C_set_evictions_enabled() */ + + +/*------------------------------------------------------------------------- * Function: H5C_set_prefix * * Purpose: Set the values of the prefix field of H5C_t. This diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 3b8d650..949f923 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -176,6 +176,18 @@ * entry is flushed to disk. * * + * In cases where memory is plentiful, and performance is an issue, it + * is useful to disable all cache evictions, and thereby postpone metadata + * writes. The following field is used to implement this. + * + * evictions_enabled: Boolean flag that is initialized to TRUE. When + * this flag is set to FALSE, the metadata cache will not + * attempt to evict entries to make space for newly protected + * entries, and instead the will grow without limit. + * + * Needless to say, this feature must be used with care. + * + * * The cache requires an index to facilitate searching for entries. The * following fields support that index. * @@ -802,6 +814,8 @@ struct H5C_t H5C_log_flush_func_t log_flush; + hbool_t evictions_enabled; + int32_t index_len; size_t index_size; H5C_cache_entry_t * (index[H5C__HASH_TABLE_LEN]); diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index d3fcbeb..e169bd6 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -37,7 +37,7 @@ #include "H5Fprivate.h" /* File access */ -#define H5C_DO_SANITY_CHECKS 0 +#define H5C_DO_SANITY_CHECKS 1 #define H5C_DO_EXTREME_SANITY_CHECKS 0 /* This sanity checking constant was picked out of the air. Increase @@ -51,7 +51,7 @@ /* H5C_COLLECT_CACHE_STATS controls overall collection of statistics * on cache activity. In general, this #define should be set to 0. */ -#define H5C_COLLECT_CACHE_STATS 0 +#define H5C_COLLECT_CACHE_STATS 1 /* H5C_COLLECT_CACHE_ENTRY_STATS controls collection of statistics * in individual cache entries. @@ -901,6 +901,9 @@ H5_DLL herr_t H5C_get_entry_status(H5C_t * cache_ptr, hbool_t * is_protected_ptr, hbool_t * is_pinned_ptr); +H5_DLL herr_t H5C_get_evictions_enabled(H5C_t * cache_ptr, + hbool_t * evictions_enabled_ptr); + H5_DLL herr_t H5C_get_trace_file_ptr(H5C_t * cache_ptr, FILE ** trace_file_ptr_ptr); @@ -955,6 +958,9 @@ H5_DLL herr_t H5C_resize_pinned_entry(H5C_t * cache_ptr, H5_DLL herr_t H5C_set_cache_auto_resize_config(H5C_t * cache_ptr, H5C_auto_size_ctl_t *config_ptr); +H5_DLL herr_t H5C_set_evictions_enabled(H5C_t * cache_ptr, + hbool_t evictions_enabled); + H5_DLL herr_t H5C_set_prefix(H5C_t * cache_ptr, char * prefix); H5_DLL herr_t H5C_set_skip_flags(H5C_t * cache_ptr, |