Files
Jungfraujoch/tools/rugnux_timing.py
T
leonarski_fandFilip Leonarski 19b135186d
Build Packages / Create release (push) Successful in 7s
Build Packages / build:portable:macos-arm64:nocuda (push) Successful in 4m56s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 9m10s
Build Packages / build:portable:linux-x86_64:nocuda (push) Successful in 13m51s
Build Packages / build:portable:linux-x86_64:cuda (push) Successful in 16m56s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 20m59s
Build Packages / build:portable:windows-x86_64:nocuda (push) Successful in 21m25s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 21m17s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 14m14s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 25m59s
Build Packages / build:portable:windows-x86_64:cuda (push) Successful in 25m48s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 15m52s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 19m33s
Build Packages / Generate python client (push) Successful in 29s
Build Packages / Build documentation (push) Successful in 1m19s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 20m49s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 25m31s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 25m24s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 26m5s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 22m19s
Build Packages / Unit tests (push) Failing after 2h28m24s
Build Packages / Validation Battery (push) Successful in 40m33s
v1.0.0-rc.175 (#85)
* Rugnux: Processes a collection live while jfjoch_broker writes it (`rugnux <master.h5> <broker URL>`).
* Rugnux: Processing starts on the first images and confirms its choices once all are in, so analysis can begin during collection.
* Rugnux: Faster processing, especially on servers with several GPUs and CPU sockets and on computers without a GPU (`--no-gpu`, macOS).
* Rugnux: Uses much less GPU memory, so large data sets stay on the GPU of smaller cards, and a data set too large for the card is processed on the CPU instead.
* Rugnux: On macOS, Bragg integration runs on the Apple GPU.
* Rugnux: Better handling of twinning and pseudo-symmetry, with the twin hypothesis written as `<prefix>_twin_<SG>.mtz`, and a wrong `--model` no longer confirms the data or decides the hand.
* Rugnux: `--model` accepts predicted (AlphaFold) models and falls back to molecular replacement when the model is not placed as a rigid body (experimental `--mr` forces it), settling space group, hand and twinning and writing a different answer as `<prefix>_mr.mtz`.
* Rugnux: Molecular replacement is faster and settles the space group in more cases with several copies in the asymmetric unit.
* Rugnux: Deposition-ready mmCIF, a richer report, and numbered steps on the terminal with the full log in `<prefix>_log.txt`; `_P1.mtz`, `--estimate-beam-center` and `--beam-center-search` are removed.
* Rugnux: The beam-stop shadow is found correctly on tilted detectors.
* Rugnux: Stills files that record a stationary goniometer axis get the default stills geometry refinement.
* jfjoch_viewer: "Analyze dataset" uses the same defaults as a bare `rugnux <file>`, and shows the results of processed CBF, marCCD and SMV sweeps.
* jfjoch_viewer: The Files panel refreshes on F5 and every few seconds, and the plot type and other selections stay put during live collection.
* jfjoch_writer: Memory stays bounded and old data files are closed efficiently on long runs, any failure ends the run in an error state the broker is told about, and the master file appears only after its data files; the ZeroMQ pusher logs when a stalled writer makes it drop images.
* Fixes: The TCP image pusher no longer blocks the broker's receiver, GPU out-of-memory failures stop with a clear message, and the XDS plugin masks module and chip edges.

---------

Co-authored-by: Filip Leonarski <jungfrau@filips-mac-mini.home>
Reviewed-on: #85
Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
2026-10-16 15:34:43 +02:00

90 lines
3.5 KiB
Python
Executable File

#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
# SPDX-License-Identifier: GPL-3.0-only
"""Tabulate the TIMING lines of a rugnux <prefix>_log.txt.
rugnux logs one debug line per timed section as it ends (TimingMark in common/Logger.h):
[2026-10-07 15:29:52.114] [Rugnux] [debug] TIMING merge P1 4.210
The section name is everything between TIMING and the last field, which is the seconds. Sections
nest: an "rsm ..." line is a part of the "merge <role>" line logged after it, and every section of
a pass ends before its "pass (...)" line.
The tail is the stretch from the end of the image pass of the last output pass to the last line of
the log. Its sections are listed in the order they ended, then summed by name.
tools/rugnux_timing.py p_log.txt # the tail
tools/rugnux_timing.py --all p_log.txt # every timed section of the run
"""
import argparse
import datetime
import re
import sys
LINE = re.compile(r'^\[(\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\.\d+)\] \[[^\]]*\] \[[^\]]*\] (.*)$')
def read(path):
marks = [] # (end time, section, seconds)
first = last = None
with open(path, errors='replace') as f:
for line in f:
m = LINE.match(line.rstrip('\n'))
if not m:
continue
t = datetime.datetime.strptime(m.group(1), '%Y-%m-%d %H:%M:%S.%f')
first = first or t
last = t
text = m.group(2)
if text.startswith('TIMING '):
section, seconds = text[len('TIMING '):].rsplit(' ', 1)
marks.append((t, section, float(seconds)))
return first, last, marks
def main():
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument('log')
ap.add_argument('--all', action='store_true', help='every timed section, not only the tail')
args = ap.parse_args()
first, last, marks = read(args.log)
if not marks:
sys.exit(f'{args.log}: no TIMING lines')
start = 0
if not args.all:
output = [i for i, m in enumerate(marks) if m[1] == 'pass (output)']
if output:
image = [i for i in range(output[-1]) if marks[i][1] == 'image pass']
start = image[-1] + 1 if image else 0
tail = marks[start:]
t0 = marks[start - 1][0] if start > 0 else first
wall = (last - t0).total_seconds()
print(f'{"ends at [s]":>11} {"seconds":>9} section')
for t, section, seconds in tail:
indent = ' ' if section.startswith('rsm ') else ''
print(f'{(t - t0).total_seconds():11.2f} {seconds:9.3f} {indent}{section}')
print()
# Shares are of the wall clock above. Sections nest (a pass holds its merges, a merge its rsm
# parts), so they do not add up to 100 %.
print(f'{"count":>5} {"seconds":>9} {"share":>6} section (summed by name; nested, so shares overlap)')
totals = {}
for _, section, seconds in tail:
n, s = totals.get(section, (0, 0.0))
totals[section] = (n + 1, s + seconds)
for section, (n, s) in sorted(totals.items(), key=lambda kv: -kv[1][1]):
share = f'{100.0 * s / wall:5.1f}%' if wall > 0 else ' -'
print(f'{n:5d} {s:9.3f} {share} {section}')
print()
origin = "the end of the last output pass's image pass" if start > 0 else 'the first log line'
print(f'{"run" if args.all else "tail"} wall clock: {wall:.2f} s, from {origin} to the last log line')
if __name__ == '__main__':
main()