Skip to content

Commit 97e049c

Browse files
committed
refactor: Add cached property for long metadata count in POSIX data handling
1 parent d567b72 commit 97e049c

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

drishti/handlers/darshan_util.py

100644100755
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import pandas as pd
1111
from darshan import DarshanReport # type: ignore
1212
import drishti.includes.parser as parser
13+
import drishti.includes.config as config
1314

1415

1516
class ModuleType(str, Enum):
@@ -272,6 +273,8 @@ class DarshanFile:
272273
_posix_read_random: Optional[int] = None
273274
_posix_write_random: Optional[int] = None
274275

276+
_posix_long_metadata_count: Optional[int] = None
277+
275278
access_pattern: Optional[AccessPatternStats] = None
276279

277280
# Use separate classes for shared operations
@@ -640,4 +643,12 @@ def posix_write_random(self) -> int:
640643
posix_df = self.report.records[ModuleType.POSIX].to_df()
641644
posix_counters = posix_df["counters"]
642645
self._posix_write_random = self.io_stats.get_module_ops(ModuleType.POSIX, "write") - self.posix_write_consecutive - self.posix_write_sequential
643-
return self._posix_write_random
646+
return self._posix_write_random
647+
648+
@cached_property
649+
def posix_long_metadata_count(self) -> int:
650+
if self._posix_long_metadata_count is None:
651+
posix_df = self.report.records[ModuleType.POSIX].to_df()
652+
posix_long_metadata_rows = posix_df['fcounters'][(posix_df['fcounters']['POSIX_F_META_TIME'] > config.thresholds['metadata_time_rank'][0])]
653+
self._posix_long_metadata_count = len(posix_long_metadata_rows)
654+
return self._posix_long_metadata_count

drishti/handlers/handle_darshan.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ def handler():
530530
shared_files = shared_files.assign(id=lambda d: d['id'].astype(str))
531531

532532
if not shared_files.empty:
533+
# TODO: This entire conditional
533534
total_shared_reads = shared_files['POSIX_READS'].sum()
534535
total_shared_reads_small = (
535536
shared_files['POSIX_SIZE_READ_0_100'].sum() +
@@ -571,7 +572,10 @@ def handler():
571572

572573
count_long_metadata = len(df['fcounters'][(df['fcounters']['POSIX_F_META_TIME'] > thresholds['metadata_time_rank'][0])])
573574

574-
module.check_long_metadata(count_long_metadata, modules)
575+
assert darshan_file_obj.posix_long_metadata_count == count_long_metadata
576+
assert darshan_file_obj.modules == modules.keys(), f"{darshan_file_obj.modules} != {modules.keys()}"
577+
# module.check_long_metadata(count_long_metadata, modules)
578+
module.check_long_metadata(count_long_metadata=darshan_file_obj.posix_long_metadata_count, modules=darshan_file_obj.modules)
575579

576580
# We already have a single line for each shared-file access
577581
# To check for stragglers, we can check the difference between the

0 commit comments

Comments
 (0)