Python tool for aircraft Doppler audio geolocation using historical ADS-B flight data (Source-available)
Python acoustic-geolocationads-baircraft-trackingairplaneaudio-forensicsdoppler-effectdoppler-shiftgeolocationosintsignal-processing
Report post-exec process memory high water on Linux
Cinna Davis746f69d5a24a
diff --git a/docs/DATA_AND_SCALE.md b/docs/DATA_AND_SCALE.mdindex 67851cd..a332c5f 100644--- a/docs/DATA_AND_SCALE.md+++ b/docs/DATA_AND_SCALE.md@@ -210,6 +210,9 @@ Reports distinguish complete/partial computation, source scope, missing tiles,refinement failure, runtime and Linux process peak RSS. A complete tile is neverlabelled a complete national search. The product/confidence workers translatethis internal report to the shared coverage and result contracts.+On Linux, process peak RSS uses the process's post-exec `VmHWM`; it does not+include worker processes or FFmpeg. Earlier `getrusage` receipts can inherit a+larger pre-exec high-water mark and should not be compared as measured peaks.Search progress counts grid-cell work, not elapsed time or a guarantee that alldata and model support are complete; dense cells may take much longer to process.diff --git a/scripts/discover_audio.py b/scripts/discover_audio.pyindex 10875f6..dcf6543 100644--- a/scripts/discover_audio.py+++ b/scripts/discover_audio.py@@ -8,12 +8,12 @@ from dataclasses import asdictimport hashlibimport jsonfrom pathlib import Path-import resourceimport subprocessimport timefrom dopplergeist.discovery import DiscoverySettings, discover_eventsfrom dopplergeist.intake import intake_recording+from dopplergeist.resource_usage import process_peak_rss_kibdef main():@@ -35,7 +35,7 @@ def main():result = {"recording": recording.metadata, "time_status": recording.time_status,"settings": asdict(DiscoverySettings()), "events_found": len(events),"events": [{k: event[k] for k in ("event_id", "start_s", "end_s", "band_hz", "quality")} for event in events],- "runtime_s": time.monotonic() - began, "peak_rss_kib": resource.getrusage(resource.RUSAGE_SELF).ru_maxrss,+ "runtime_s": time.monotonic() - began, "peak_rss_kib": process_peak_rss_kib(),"code_sha256": code_hash.hexdigest(),"git_commit": subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=root, text=True).strip(),"working_tree": subprocess.check_output(["git", "status", "--short"], cwd=root, text=True).strip(),diff --git a/src/dopplergeist/resource_usage.py b/src/dopplergeist/resource_usage.pynew file mode 100644index 0000000..043989e--- /dev/null+++ b/src/dopplergeist/resource_usage.py@@ -0,0 +1,23 @@+"""Process-local resource measurements."""+import resource+import sys+++def process_peak_rss_kib():+ """Return process peak RSS in KiB; do not include child processes.++ Linux getrusage may retain a larger high-water mark from a pre-exec+ parent. Its VmHWM reports the post-exec address space instead. Other+ systems fall back to their getrusage semantics.+ """+ try:+ with open('/proc/self/status', encoding='ascii') as status:+ for line in status:+ if line.startswith('VmHWM:'):+ fields = line.split()+ if len(fields) == 3 and fields[2] == 'kB':+ return int(fields[1])+ except (OSError, ValueError):+ pass+ peak = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss+ return peak / 1024 if sys.platform == 'darwin' else peakdiff --git a/src/dopplergeist/tiled_search.py b/src/dopplergeist/tiled_search.pyindex 55147f5..f3e5a4d 100644--- a/src/dopplergeist/tiled_search.py+++ b/src/dopplergeist/tiled_search.py@@ -12,7 +12,6 @@ import jsonimport mathimport platformfrom pathlib import Path-import resourceimport timeimport numpy as np@@ -21,6 +20,7 @@ from pyproj import Transformerfrom .data_access import CONUS, DataUnavailable, content_hash, sha256, write_jsonfrom .finite_search import RetentionLedger, bounded_assessment, classified_assessment, identify_mode, mode_seed+from .resource_usage import process_peak_rss_kibfrom .geometry import AcousticSupportError, eceffrom .matching import _cache_ridge_fitsfrom .search import cpa_table, filter_association_event, pair_candidates, score_candidate@@ -966,7 +966,7 @@ def search_national(indexes, terrain, events, measurements, *, time_range_s, out"event_groups_proposed": len(events), "association_event_limit": event_limit,"all_event_groups_considered": not event_limit_applied,"event_limit_reason": "Configured event cap prevents assessing every independent group" if event_limit_applied else None,- "elapsed_s": time.monotonic() - began, "process_peak_rss_mib": resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1024,+ "elapsed_s": time.monotonic() - began, "process_peak_rss_mib": process_peak_rss_kib() / 1024,"bounded_concurrency": workers if parallel else 1, "max_grid_points_per_tile": budget.tile_cells ** 2,"scoring_time_is_locked": True, "ground_truth_used_by_search": False, "scope": list(bounds)}write_json(output / "search-report.json", report)diff --git a/tests/test_process_peak_rss.py b/tests/test_process_peak_rss.pynew file mode 100644index 0000000..5d8542d--- /dev/null+++ b/tests/test_process_peak_rss.py@@ -0,0 +1,30 @@+"""Reproduce inherited RSS high-water marks without audio fixtures."""+import json+import subprocess+import sys++import pytest++[email protected](not sys.platform.startswith("linux"), reason="Linux VmHWM regression")+def test_child_reports_its_own_post_exec_high_water():+ child = r'''+import json, resource+from dopplergeist.resource_usage import process_peak_rss_kib+measured = process_peak_rss_kib()+with open('/proc/self/status') as f:+ actual = int(next(line for line in f if line.startswith('VmHWM:')).split()[1])+print(json.dumps({'reported': measured, 'vmhwm': actual,+ 'getrusage': resource.getrusage(resource.RUSAGE_SELF).ru_maxrss}))+'''+ parent = r'''+import subprocess, sys+allocation = bytearray(160 * 1024 * 1024)+allocation[0] = 1+result = subprocess.check_output([sys.executable, '-c', sys.argv[1]], text=True)+print(result, end='')+'''+ result = subprocess.run([sys.executable, "-c", parent, child], check=True,+ capture_output=True, text=True)+ observed = json.loads(result.stdout)+ assert abs(observed["vmhwm"] - observed["reported"]) <= 1024diff --git a/tests/test_real_clock_partitions.py b/tests/test_real_clock_partitions.pyindex b985c14..c02151a 100644--- a/tests/test_real_clock_partitions.py+++ b/tests/test_real_clock_partitions.py@@ -111,6 +111,10 @@ def test_real_clock_partition_restart_and_scores(tmp_path, monkeypatch):pytest.fail("sparse search should not use the acoustic batch cache")patch.setattr(_RidgeFitCache, "acoustic_batch", unexpected_cache)baseline = run("baseline")+ if Path('/proc/self/status').exists():+ with open('/proc/self/status') as status:+ actual_peak = int(next(line for line in status if line.startswith('VmHWM:')).split()[1]) / 1024+ assert abs(baseline['process_peak_rss_mib'] - actual_peak) <= 2original = tiled._scoredef force_split(*args, **kwargs):if kwargs.get("anchor_window") is None: