@@ -633,7 +633,6 @@ def _log_get_heatmap_record(log):
633633 buf = ffi .new ("void **" )
634634 r = libdutil .darshan_log_get_record (log ['handle' ], modules [mod_name ]['idx' ], buf )
635635 if r < 1 :
636- libdutil .darshan_free (buf [0 ])
637636 return None
638637
639638 filerec = ffi .cast (mod_type , buf )
@@ -660,6 +659,7 @@ def _log_get_heatmap_record(log):
660659 return rec
661660
662661
662+ @functools .lru_cache ()
663663def log_get_derived_metrics (log_path : str , mod_name : str ):
664664 """
665665 Returns the darshan_derived_metrics struct from CFFI/C accumulator code.
@@ -716,24 +716,13 @@ def log_get_derived_metrics(log_path: str, mod_name: str):
716716 r = libdutil .darshan_accumulator_emit (darshan_accumulator [0 ],
717717 darshan_derived_metrics ,
718718 rbuf [0 ])
719+ libdutil .darshan_free (buf [0 ])
720+ libdutil .darshan_accumulator_destroy (darshan_accumulator [0 ])
721+ log_close (log_handle )
719722 if r != 0 :
720- libdutil .darshan_free (buf [0 ])
721723 raise RuntimeError ("A nonzero exit code was received from "
722724 "darshan_accumulator_emit() at the C level. "
723725 "It may be possible "
724726 "to retrieve additional information from the stderr "
725727 "stream." )
726- libdutil .darshan_free (buf [0 ])
727728 return darshan_derived_metrics
728-
729-
730- def log_get_bytes_bandwidth (log_path : str , mod_name : str ) -> str :
731- # get total bytes (in MiB) and bandwidth (in MiB/s) for
732- # a given module -- this information was commonly reported
733- # in the old perl-based summary reports
734- darshan_derived_metrics = log_get_derived_metrics (log_path = log_path ,
735- mod_name = mod_name )
736- total_mib = darshan_derived_metrics .total_bytes / 2 ** 20
737- total_bw = darshan_derived_metrics .agg_perf_by_slowest
738- ret_str = f"I/O performance estimate (at the { mod_name } layer): transferred { total_mib :.1f} MiB at { total_bw :.2f} MiB/s"
739- return ret_str
0 commit comments