feat: per-locus CPU-time profiling (thread CPU time + harness)#15
Merged
Conversation
Measure per-locus genotyping cost by thread CPU time instead of wall clock, so timings are not inflated when other processes contend for the machine. Each locus is genotyped start-to-finish on a single rayon worker, so the thread-CPU delta around it is that locus's CPU cost. - repeats.rs: add thread_cpu_time() (clock_gettime(CLOCK_THREAD_CPUTIME_ID), hence the libc dep), store it in RepeatInterval.created (now a Duration), and add cpu_elapsed()/time_field() helpers. - vcf.rs: the debug-only ;TIME= INFO field now reports thread CPU seconds; the four duplicated timing blocks collapse to repeat.time_field(args.debug). - misc/profile_loci.py: run STRdust over N replicates, drop warmup runs, aggregate per-locus median/MAD/CV CPU time and correlate with VCF features (depth, allele length, stdev, cluster count, ...) to find consistently slow loci. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds per-locus profiling instrumentation and an analysis harness to find which loci are consistently slow and why.
Why
The debug-only
;TIME=INFO field measured wall-clock time, which is inflated whenever other processes contend for the machine — making per-locus timings unreliable across runs.What
TIME=now reports thread CPU time viarepeats::thread_cpu_time()(clock_gettime(CLOCK_THREAD_CPUTIME_ID), hence thelibcdep). This only advances while the thread is on-CPU, so it's immune to other-process noise. Valid here because each locus is genotyped start-to-finish on a single rayon worker, so the thread-CPU delta around it is exactly that locus's cost. Stays correct under multi-threading too.RepeatInterval.createdis now aDuration; newcpu_elapsed()/time_field()helpers collapse the four duplicated timing blocks invcf.rs.misc/profile_loci.py. Runs STRdust over N replicates, drops--warmupcold-cache runs, and aggregates per-locus median / MAD / CV CPU time, joining each locus with VCF features (depth, allele length, stdev, cluster count, outliers, QUICKREF). Prints the consistently-slowest loci and Spearman feature correlations.--from-vcfsre-aggregates existing debug VCFs without rerunning.Findings (chr22:20–21 Mb, 1607 loci, 4 replicates)
So this is a diagnostic tool, not itself a speedup — but it cleanly ruled out feature-based heuristics and the read-slicing direction.
Notes
0.19.0chore already onmain.libcwas already in the lockfile transitively; the direct dep adds a single line.