Skip to content

Commit 9951500

Browse files
committed
refactor: Introduce cached properties for memory and file alignment checks in Darshan data handling
1 parent 0ff644b commit 9951500

File tree

2 files changed

+37
-5
lines changed

2 files changed

+37
-5
lines changed

drishti/handlers/darshan_util.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ class DarshanFile:
262262
_posix_detected_small_files: Optional[pd.DataFrame] = None
263263

264264
# Direct alignment fields instead of a class
265-
mem_not_aligned: Optional[int] = None
266-
file_not_aligned: Optional[int] = None
265+
_mem_not_aligned: Optional[int] = None
266+
_file_not_aligned: Optional[int] = None
267267

268268
access_pattern: Optional[AccessPatternStats] = None
269269

@@ -547,4 +547,26 @@ def dxt_posix_write_df(self) -> Optional[pd.DataFrame]:
547547
'offsets': write_offsets,
548548
})
549549

550-
return pd.DataFrame(dxt_posix_write_data)
550+
return pd.DataFrame(dxt_posix_write_data)
551+
552+
@cached_property
553+
def mem_not_aligned(self) -> int:
554+
if self._mem_not_aligned is None:
555+
posix_df = self.report.records[ModuleType.POSIX].to_df()
556+
posix_counters = posix_df["counters"]
557+
self._mem_not_aligned = posix_counters['POSIX_MEM_NOT_ALIGNED'].sum()
558+
return self._mem_not_aligned
559+
560+
@cached_property
561+
def file_not_aligned(self) -> int:
562+
if self._file_not_aligned is None:
563+
posix_df = self.report.records[ModuleType.POSIX].to_df()
564+
posix_counters = posix_df["counters"]
565+
self._file_not_aligned = posix_counters['POSIX_FILE_NOT_ALIGNED'].sum()
566+
return self._file_not_aligned
567+
568+
@property
569+
def lustre_df(self) -> Optional[pd.DataFrame]:
570+
if "LUSTRE" not in self.modules:
571+
return None
572+
return pd.DataFrame(self.report.records["LUSTRE"].to_df())

drishti/handlers/handle_darshan.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def handler():
358358
total_writes = df['counters']['POSIX_WRITES'].sum()
359359

360360
# Get total number of I/O operations
361-
total_operations = total_writes + total_reads
361+
total_operations = total_writes + total_reads
362362

363363
# To check whether the application is write-intensive or read-intensive we only look at the POSIX level and check if the difference between reads and writes is larger than 10% (for more or less), otherwise we assume a balance
364364
# module.check_operation_intensive(total_operations, total_reads, total_writes)
@@ -443,7 +443,17 @@ def handler():
443443
total_mem_not_aligned = df['counters']['POSIX_MEM_NOT_ALIGNED'].sum()
444444
total_file_not_aligned = df['counters']['POSIX_FILE_NOT_ALIGNED'].sum()
445445

446-
module.check_misaligned(total_operations, total_mem_not_aligned, total_file_not_aligned, modules, file_map, df_lustre, dxt_posix, dxt_posix_read_data)
446+
# module.check_misaligned(total_operations, total_mem_not_aligned, total_file_not_aligned, modules, file_map, df_lustre, dxt_posix, dxt_posix_read_data)
447+
module.check_misaligned(
448+
total_operations=darshan_file_obj.io_stats.posix_ops,
449+
total_mem_not_aligned=darshan_file_obj.mem_not_aligned,
450+
total_file_not_aligned=darshan_file_obj.file_not_aligned,
451+
modules=darshan_file_obj.modules,
452+
file_map=darshan_file_obj.file_map,
453+
df_lustre=darshan_file_obj.lustre_df,
454+
dxt_posix=darshan_file_obj.dxt_posix_df,
455+
dxt_posix_read_data=darshan_file_obj.dxt_posix_read_df,
456+
)
447457

448458
#########################################################################################################################################################################
449459

0 commit comments

Comments
 (0)