Skip to content

Commit 3375e4d

Browse files
Turn off tracemalloc
1 parent e357fff commit 3375e4d

1 file changed

Lines changed: 0 additions & 46 deletions

File tree

tsinfer/pipeline.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,11 @@
2424

2525
import collections
2626
import dataclasses
27-
import gc
2827
import json
2928
import logging
3029
import pathlib
3130
import sys
3231
import time as time_
33-
import tracemalloc
3432

3533
import numpy as np
3634
import psutil
@@ -379,11 +377,6 @@ def _process_group(
379377
results = []
380378
last_mem_log = time_.monotonic()
381379
mem_log_interval = 30 # seconds
382-
383-
# Memory diagnostics: tracemalloc for Python allocations
384-
tracemalloc.start()
385-
tm_snapshot_prev = tracemalloc.take_snapshot()
386-
387380
for job, result in match_iter:
388381
if match_fh is not None:
389382
doc = {
@@ -416,46 +409,7 @@ def _process_group(
416409
len(job_list),
417410
rss_mib,
418411
)
419-
420-
# GC diagnostics
421-
pre_gc_rss = rss_mib
422-
collected = gc.collect()
423-
post_gc_rss = psutil.Process().memory_info().rss / (1024 * 1024)
424-
logger.info(
425-
"Group %d GC: collected=%d objects,"
426-
" RSS %.1f -> %.1f MiB"
427-
" (freed=%.1f MiB)",
428-
group_idx,
429-
collected,
430-
pre_gc_rss,
431-
post_gc_rss,
432-
pre_gc_rss - post_gc_rss,
433-
)
434-
435-
# tracemalloc top growers
436-
tm_snapshot = tracemalloc.take_snapshot()
437-
tm_traced_mib = tracemalloc.get_traced_memory()[0] / (1024 * 1024)
438-
stats = tm_snapshot.compare_to(tm_snapshot_prev, "lineno")
439-
top_lines = []
440-
for s in stats[:5]:
441-
top_lines.append(
442-
f" {s.traceback}: "
443-
f"{s.size_diff / (1024 * 1024):+.1f} MiB"
444-
f" (total={s.size / (1024 * 1024):.1f} MiB)"
445-
)
446-
logger.info(
447-
"Group %d tracemalloc: traced=%.1f MiB,"
448-
" untraced=%.1f MiB,"
449-
" top 5 growers since last snapshot:\n%s",
450-
group_idx,
451-
tm_traced_mib,
452-
post_gc_rss - tm_traced_mib,
453-
"\n".join(top_lines),
454-
)
455-
tm_snapshot_prev = tm_snapshot
456412
last_mem_log = now
457-
458-
tracemalloc.stop()
459413
pbar.close()
460414
paired_results = sorted(results, key=lambda pair: pair[0].haplotype_index)
461415

0 commit comments

Comments
 (0)