Python tool for aircraft Doppler audio geolocation using historical ADS-B flight data (Source-available)
Python acoustic-geolocationads-baircraft-trackingairplaneaudio-forensicsdoppler-effectdoppler-shiftgeolocationosintsignal-processing
Preserve current-main CPA cache contracts and document measured acceleration
Cinna Davise5351f6d346d
diff --cc .github/workflows/real-performance.ymlindex b30c361,e7a813c..9893f56--- a/.github/workflows/real-performance.yml+++ b/.github/workflows/real-performance.yml@@@ -3,15 -3,11 +3,15 @@@ onworkflow_dispatch:inputs:baseline:- description: Scalar-consistent baseline commit- default: d7cc1dd2e8089768253492b3269dfae97b3ad1a4+ description: Exact baseline commit for both real-input comparisons- default: fec518e51f14afe8d36203e6c5e1be1277dea14e++ default: c37128bb08f12b8a68cf1f1cbf86adc2436f60fdrequired: true+ regional:+ description: Also compare the complete regional HTTP workflow+ type: boolean+ default: truepush:- branches: [perf/measured-hotpath-20261103, perf/real-pipeline-throughput-20261103]+ branches: [perf/measured-hotpath-20261103, perf/real-pipeline-throughput-20261103, perf/single-pass-motion-20261103]paths:- .github/workflows/real-performance.yml- src/dopplergeist/**@@@ -31,14 -24,6 +31,14 @@@- tests/data/reference-retention-real.jsonpermissions:contents: read+env:+ OPENBLAS_NUM_THREADS: '1'+ OMP_NUM_THREADS: '1'+ MKL_NUM_THREADS: '1'+ NUMEXPR_NUM_THREADS: '1'+ CC: gcc+ PYTHONPATH: src- BASELINE_REF: ${{ inputs.baseline || 'fec518e51f14afe8d36203e6c5e1be1277dea14e' }}++ BASELINE_REF: ${{ inputs.baseline || 'c37128bb08f12b8a68cf1f1cbf86adc2436f60fd' }}jobs:compare:if: github.event_name != 'push' || github.ref != 'refs/heads/perf/real-pipeline-throughput-20261103'@@@ -72,9 -53,6 +72,12 @@@python scripts/prepare_reference_upload.py --data-root data --output benchmark-inputsbaseline_commit=$(git rev-parse --verify --end-of-options "${BASELINE_REF}^{commit}")git worktree add --detach "$RUNNER_TEMP/baseline" "$baseline_commit"+ if [ -f "$RUNNER_TEMP/baseline/setup.py" ]; then+ (cd "$RUNNER_TEMP/baseline" && python setup.py build_ext --inplace)+ fi++ mkdir -p benchmark-inputs/reference-checkout++ ln -s "$GITHUB_WORKSPACE/evidence/results" benchmark-inputs/reference-checkout/results++ ln -s "$GITHUB_WORKSPACE/data" benchmark-inputs/reference-checkout/data- name: Freeze real workloadsrun: |for width in 120 10; do@@@ -88,58 -61,12 +91,60 @@@- name: Real-input regression testsenv:DOPPLERGEIST_REAL_CPA_FIXTURE: benchmark-inputs/point-120.json- run: python -m pytest -q tests/test_real_prepared_measurements.py tests/test_real_geometry_kinematics.py tests/test_real_batch_scalar_parity.py tests/test_real_motion_support_batch.py tests/test_real_single_pass_sieve.py tests/test_real_refinement_lookup.py tests/test_real_cpa_preparation.py tests/test_real_native_ridge.py tests/test_real_ridge_backend.py tests/test_real_legacy_batch_cache.py tests/test_real_native_acoustic.py tests/test_real_native_acoustic_pipeline.py tests/test_real_batch_ceilings.py tests/test_real_acoustic_screen_cache.py- run: python -m pytest -q tests/test_real_prepared_measurements.py tests/test_real_geometry_kinematics.py tests/test_real_batch_scalar_parity.py++ DOPPLERGEIST_REAL_REFERENCE_ROOT: benchmark-inputs/reference-checkout++ DOPPLERGEIST_REAL_REFERENCE_DISCOVERY: evidence/audio/w1-sensitivity-20261102/reference/discovery.json++ run: python -m pytest -q tests/test_real_prepared_measurements.py tests/test_real_geometry_kinematics.py tests/test_real_batch_scalar_parity.py tests/test_real_motion_support_batch.py tests/test_real_single_pass_sieve.py tests/test_real_refinement_lookup.py tests/test_real_cpa_preparation.py tests/test_real_native_ridge.py tests/test_real_ridge_backend.py tests/test_real_legacy_batch_cache.py tests/test_real_native_acoustic.py tests/test_real_native_acoustic_pipeline.py tests/test_real_batch_ceilings.py tests/test_real_acoustic_screen_cache.py tests/test_real_cpa_spatial_sieve.py+ - name: Verify the explicit Python fallback on recorded arithmetic+ env:+ DOPPLERGEIST_REAL_CPA_FIXTURE: benchmark-inputs/point-120.json+ DOPPLERGEIST_RIDGE_BACKEND: python+ DOPPLERGEIST_ACOUSTIC_BACKEND: python+ run: python -m pytest -q tests/test_real_batch_scalar_parity.py tests/test_real_legacy_batch_cache.py+ - name: Compare real CPA preparation+ run: python scripts/benchmark_real_cpa_rows.py --baseline-source "$RUNNER_TEMP/baseline/src" --output results/cpa-rows.json --repeats 5 --iterations 20- name: Compare complete payloads and timingsrun: |+ native_option=()+ if [ -f src/dopplergeist/_native_ridge.c ]; then+ native_option=(--require-current-native)+ fi+ if [ -f src/dopplergeist/_native_acoustic.c ]; then+ native_option+=(--require-current-native-acoustic)+ fifor width in 10 120; do- python scripts/benchmark_prepared_measurements.py compare --fixture "benchmark-inputs/point-$width.json" --baseline-source "$RUNNER_TEMP/baseline/src" --current-source src --repeats 2 --timeout-s 600 --output "results/performance-$width"+ python scripts/benchmark_prepared_measurements.py compare --fixture "benchmark-inputs/point-$width.json" --baseline-source "$RUNNER_TEMP/baseline/src" --current-source src --repeats 2 --timeout-s 600 --output "results/performance-$width" "${native_option[@]}"done+ - name: Profile remaining point work outside the timing comparison+ run: |+ python -m cProfile -o results/current-point.prof scripts/benchmark_prepared_measurements.py _worker --source src --fixture benchmark-inputs/point-120.json --output results/current-point-profile --require-native --require-native-acoustic+ python - <<'PY'+ import json+ from pathlib import Path+ import pstats++ statistics = pstats.Stats("results/current-point.prof")+ root = Path.cwd()+ records = []+ for (filename, line, function), (primitive, total, own, cumulative, callers) in statistics.stats.items():+ path = Path(filename)+ relative = path.relative_to(root).as_posix() if path.is_relative_to(root) else filename+ module = (relative[4:-3].replace("/", ".") if relative.startswith("src/")+ and relative.endswith(".py") else path.stem)+ records.append({"module": module, "file": relative, "line": line, "function": function,+ "primitive_calls": primitive, "total_calls": total,+ "self_seconds": own, "cumulative_seconds": cumulative})+ records.sort(key=lambda row: (-row["cumulative_seconds"], -row["self_seconds"],+ row["file"], row["line"], row["function"]))+ summary = {"scope": "Separate profiled width-120 worker, including imports and input loading; excluded from timing medians",+ "timer": "cProfile default elapsed timer; diagnostic attribution, not an uninstrumented CPU measurement",+ "total_calls": statistics.total_calls, "primitive_calls": statistics.prim_calls,+ "total_profiled_seconds": statistics.total_tt, "top_50": records[:50],+ "dopplergeist_functions": [row for row in records if row["module"].startswith("dopplergeist")]}+ output = Path("results/current-point-profile-stats.json")+ output.write_text(json.dumps(summary, indent=2) + "\n")+ print(json.dumps({"profile_summary": str(output), "excluded_from_timing_medians": True,+ "top_10": records[:10]}, indent=2))+ PY- uses: actions/upload-artifact@v4if: always()with:diff --cc README.mdindex e7d076f,973167a..97f50da--- a/README.md+++ b/README.md@@@ -103,6 -101,6 +103,8 @@@ Recording-time evidence matters: audio-The automatic search uses conservative score ceilings before completing every fit: incompatible residuals and an established Top-K cutoff can stop further group fitting at a shared clock. It batches eligible clock fits, reuses exact acoustic calculations in dense tiles, and divides overloaded areas or single-cell clock ranges into checkpointed pieces. [Search screening and real-data timing](docs/DATA_AND_SCALE.md#search) describe the bounds and their measured limits.++The optional native backends and bounded calculation reuse completed the full regional HTTP replay in **62.03 → 37.19 seconds**, a **1.67× speedup with 40.05% less elapsed time**, across three alternating pairs. Broad-clock point scoring improved **1.81×**. Scientific outputs matched exactly; both HTTP arms retained 17 ridge records, 15 independent groups, 23 candidates, and `inconclusive / search_incomplete`. These measurements compare `41d0646` with the already optimized main baseline `fec518e5`. See [the measured results and reproduction instructions](docs/PERFORMANCE.md#measured-native-computation-and-bounded-reuse) for the source pins, runtime, memory tradeoff, and scope. The earlier results below use different sources and environments.++The integrated implementation [`66146714`](https://github.com/1337isnot1337/DOPPLERGEIST/commit/66146714c6c22a448a7a54830a82d31034c2be44) completed a fresh bounded HTTP comparison in **78.38 → 54.18 wall seconds**, an observed **1.45×** speedup over baseline `aa3dff6`. This is **30.88% less elapsed time** in one sequential pair on the same CI runner. Both arms used one shared fresh encoding of the complete published recording, with the same flight data, terrain, and budgets. Both returned 16 event records and 23 candidates with `inconclusive / search_incomplete`. Scientific JSON, the logical retention ledger, decoded audio, CSV values, and PNG pixels matched exactly after the declared metadata normalization. All **38 selected real-input tests passed**, with no skips; standard Python 3.11 and 3.14 CI also passed. The [integrated measurement record](benchmarks/results/integrated-http-20261103.json) and [performance report](docs/PERFORMANCE.md#integration-with-main-verified) preserve the source pins, runtime, scope, and comparisons.The original PR225 comparison used source `5699a657` against baseline `aa3dff6`. Median scoring time at one source-informed receiver point fell from **28.80 to 15.57 CPU seconds**, a **1.85×** speedup. A narrower clock workload improved from **4.39 to 2.21 CPU seconds**, or **1.98×**. Each comparison used three alternating pairs on actual recorded ridges and observed flight trajectories. All 3,905 broad-window associations and 1,055 narrow-window associations matched exactly across 16 independent groups, including diagnostics and retention records.diff --cc benchmarks/results/exact-native-pipeline-20261103.jsonindex 0000000,0000000..4b15af8new file mode 100644--- /dev/null+++ b/benchmarks/results/exact-native-pipeline-20261103.json@@@ -1,0 -1,0 +1,433 @@@++{++ "scope": "Exact computation comparison on one real recording and archived observed trajectories; source-informed receiver region and recording clock.",++ "baseline_revision": "fec518e51f14afe8d36203e6c5e1be1277dea14e",++ "current_revision": "41d06469935f776988e1a4f04ab386d0355b433b",++ "workflow_url": "https://github.com/1337isnot1337/DOPPLERGEIST/actions/runs/41685506906",++ "http": {++ "pairs": 3,++ "arm_order": [++ [++ "baseline",++ "current"++ ],++ [++ "current",++ "baseline"++ ],++ [++ "baseline",++ "current"++ ]++ ],++ "runtime": {++ "audio_sha256": "707083f0344823eeea7f130faec6c22b6628b8b9fea04d026915d93df9a07b15",++ "audio_bytes": 43202925,++ "python": "3.12.16",++ "sqlite": "3.45.1",++ "numerical_package_versions": {++ "numpy": "2.5.4",++ "scipy": "1.18.1",++ "pandas": "3.1.0",++ "pyarrow": "26.0.1",++ "pyproj": "3.8.0",++ "rasterio": "1.5.2",++ "soundfile": "0.14.0"++ },++ "numerical_threads": 1,++ "cpu_affinity": [++ 0++ ],++ "detail_plots_enabled": false,++ "recording_control": "fixed_counts",++ "reference_wav_sha256": "262d9c4eba1c80657813c604140ba2afbbaabed2b3aebc833cba7cafdc005e9f",++ "ffmpeg_version": "ffmpeg version 6.1.1-3ubuntu5 Copyright (c) 2000-2023 the FFmpeg developers"++ },++ "request": {++ "bounds_wsen": [++ -73.545,++ 40.865,++ -73.505,++ 40.895++ ],++ "start_utc": "2026-09-08T20:17:20Z",++ "end_utc": "2026-09-08T20:17:40Z"++ },++ "operator": {++ "offline": true,++ "search_workers": 1,++ "spacing_m": 2000,++ "tile_cells": 16,++ "top_k": 20,++ "refine_spacing_m": 500,++ "refine_finalists": 3++ },++ "medians": {++ "baseline": {++ "http_receipt_seconds": 62.03129542500005,++ "driver_wall_seconds": 62.03649870099997,++ "driver_cpu_seconds": 61.60743099999999++ },++ "current": {++ "http_receipt_seconds": 37.187638357000026,++ "driver_wall_seconds": 37.19352836300004,++ "driver_cpu_seconds": 36.863444++ }++ },++ "speedup": {++ "http_receipt_seconds": 1.6680622423371387,++ "driver_wall_seconds": 1.6679379836066752,++ "driver_cpu_seconds": 1.6712337295451827++ },++ "wall_time_reduction_percent": 40.05019869049431,++ "samples": {++ "baseline": [++ {++ "http_receipt_seconds": 62.42229257599999,++ "wall_s": 62.427504107000004,++ "cpu_s": 61.60743099999999++ },++ {++ "http_receipt_seconds": 61.860873814,++ "wall_s": 61.866216323,++ "cpu_s": 61.568397++ },++ {++ "http_receipt_seconds": 62.03129542500005,++ "wall_s": 62.03649870099997,++ "cpu_s": 61.71801++ }++ ],++ "current": [++ {++ "http_receipt_seconds": 37.105990709999986,++ "wall_s": 37.11119244599999,++ "cpu_s": 36.817617999999996++ },++ {++ "http_receipt_seconds": 38.20585379200003,++ "wall_s": 38.211619369999994,++ "cpu_s": 37.869552++ },++ {++ "http_receipt_seconds": 37.187638357000026,++ "wall_s": 37.19352836300004,++ "cpu_s": 36.863444++ }++ ]++ },++ "all_pairs_exact": true,++ "checked_per_pair": {++ "json": 20,++ "sqlite": 1,++ "root_json": 3++ },++ "array_checks_per_pair": {++ "intake_diagnostics": 1,++ "decoded_pcm": 1,++ "csv": 17,++ "npz": 0,++ "npz_arrays": 0,++ "png": 1++ },++ "equal_ledger_rows_per_arm": {++ "bounds": 29738,++ "records": 852,++ "run": 1,++ "stages": 12++ },++ "outcome_per_arm": {++ "status": "inconclusive",++ "reason_code": "search_incomplete",++ "candidate_count": 23,++ "event_count": 17,++ "independent_groups": 15++ }++ },++ "point_scoring": [++ {++ "clock_half_width_s": 10,++ "pairs": 2,++ "exact_outputs": true,++ "medians": {++ "baseline": {++ "wall_seconds": 2.1638290015000052,++ "cpu_seconds": 2.1616306375,++ "peak_rss_mib": 323.314453125++ },++ "current": {++ "wall_seconds": 1.2728458855000042,++ "cpu_seconds": 1.2699631694999998,++ "peak_rss_mib": 322.49609375++ }++ },++ "speedup": {++ "wall_seconds": 1.6999929262056745,++ "cpu_seconds": 1.702120730281541++ },++ "scored_candidates": 1055,++ "retained": 100,++ "independent_groups": 16,++ "native_successes_per_timed_call": {++ "ridge": 1573,++ "acoustic": 53++ },++ "samples": [++ {++ "source": "baseline",++ "repetition": 1,++ "wall_seconds": 2.1702617150000094,++ "cpu_seconds": 2.167912101,++ "peak_rss_mib": 323.64453125++ },++ {++ "source": "current",++ "repetition": 1,++ "wall_seconds": 1.2727041260000078,++ "cpu_seconds": 1.269209664,++ "peak_rss_mib": 322.5++ },++ {++ "source": "current",++ "repetition": 2,++ "wall_seconds": 1.2729876450000006,++ "cpu_seconds": 1.2707166749999996,++ "peak_rss_mib": 322.4921875++ },++ {++ "source": "baseline",++ "repetition": 2,++ "wall_seconds": 2.157396288000001,++ "cpu_seconds": 2.155349174,++ "peak_rss_mib": 322.984375++ }++ ]++ },++ {++ "clock_half_width_s": 120,++ "pairs": 2,++ "exact_outputs": true,++ "medians": {++ "baseline": {++ "wall_seconds": 13.857766631000018,++ "cpu_seconds": 13.852561589500002,++ "peak_rss_mib": 381.921875++ },++ "current": {++ "wall_seconds": 7.651596271500026,++ "cpu_seconds": 7.647479859000001,++ "peak_rss_mib": 383.830078125++ }++ },++ "speedup": {++ "wall_seconds": 1.811094853843266,++ "cpu_seconds": 1.8113890909039139++ },++ "scored_candidates": 3905,++ "retained": 100,++ "independent_groups": 16,++ "native_successes_per_timed_call": {++ "ridge": 38890,++ "acoustic": 850++ },++ "samples": [++ {++ "source": "baseline",++ "repetition": 1,++ "wall_seconds": 13.776222869999998,++ "cpu_seconds": 13.771302822000003,++ "peak_rss_mib": 381.5390625++ },++ {++ "source": "current",++ "repetition": 1,++ "wall_seconds": 7.6475400500000035,++ "cpu_seconds": 7.643168895,++ "peak_rss_mib": 383.76171875++ },++ {++ "source": "current",++ "repetition": 2,++ "wall_seconds": 7.655652493000048,++ "cpu_seconds": 7.651790823000001,++ "peak_rss_mib": 383.8984375++ },++ {++ "source": "baseline",++ "repetition": 2,++ "wall_seconds": 13.939310392000039,++ "cpu_seconds": 13.933820357,++ "peak_rss_mib": 382.3046875++ }++ ]++ }++ ],++ "limitations": [++ "Only within-run arm ratios are comparable; runner hardware and runtimes can differ between workflow runs.",++ "Input restoration, index preparation and MP3 encoding are outside the timed HTTP arms.",++ "Processes and output directories are fresh; operating-system page caches are not purged.",++ "Point timings exclude input loading; point RSS covers worker lifetime through scoring.",++ "Native acceleration was measured on Linux x86-64; macOS and Windows timing/parity were not measured.",++ "Search remains incomplete on the recorded regional control. These results do not establish independent location accuracy or nationwide completion time.",++ "Component speedups and overlapping profile times must not be multiplied or added into a whole-pipeline estimate."++ ],++ "point_runtime": {++ "python": "3.12.15",++ "numpy": "2.5.4",++ "pandas": "3.1.0",++ "cpu_affinity": [++ 0,++ 1,++ 2,++ 3++ ]++ },++ "validation": {++ "selected_recorded_input_tests_passed": 78,++ "main_suite_skipped": 0,++ "explicit_python_fallback_at_measured_checkpoint": {++ "passed": 1,++ "skipped": 3,++ "cause": "Missing DOPPLERGEIST_REAL_CPA_FIXTURE in the fallback step; fixed in d935180 for the integration gate."++ }++ },++ "integration_confirmation": {++ "current_revision": "d93518010345a921b09722b8d7fc4ca1961c396e",++ "baseline_revision": "fec518e51f14afe8d36203e6c5e1be1277dea14e",++ "integrated_main_revision": "b149d894cad41644ecb637bf49e8e9cdbcc95394",++ "workflow_url": "https://github.com/1337isnot1337/DOPPLERGEIST/actions/runs/41687118475",++ "installation_workflow_url": "https://github.com/1337isnot1337/DOPPLERGEIST/actions/runs/41687129205",++ "recorded_tests_passed": 78,++ "explicit_python_tests_passed": 4,++ "tests_skipped": 0,++ "installation_python_versions_passed": [++ "3.11",++ "3.14"++ ],++ "http": {++ "pairs": 3,++ "all_pairs_exact": true,++ "runtime": {++ "audio_sha256": "707083f0344823eeea7f130faec6c22b6628b8b9fea04d026915d93df9a07b15",++ "audio_bytes": 43202925,++ "python": "3.12.15",++ "sqlite": "3.45.1",++ "numerical_package_versions": {++ "numpy": "2.5.4",++ "scipy": "1.18.1",++ "pandas": "3.1.0",++ "pyarrow": "26.0.1",++ "pyproj": "3.8.0",++ "rasterio": "1.5.2",++ "soundfile": "0.14.0"++ },++ "numerical_threads": 1,++ "cpu_affinity": [++ 0++ ],++ "detail_plots_enabled": false,++ "recording_control": "fixed_counts",++ "reference_wav_sha256": "262d9c4eba1c80657813c604140ba2afbbaabed2b3aebc833cba7cafdc005e9f",++ "ffmpeg_version": "ffmpeg version 6.1.1-3ubuntu5 Copyright (c) 2000-2023 the FFmpeg developers"++ },++ "medians": {++ "baseline": {++ "http_receipt_seconds": 90.86300797699994,++ "driver_wall_seconds": 90.87042387300005,++ "driver_cpu_seconds": 88.861937++ },++ "current": {++ "http_receipt_seconds": 53.700215961000026,++ "driver_wall_seconds": 53.70792494599999,++ "driver_cpu_seconds": 53.148115++ }++ },++ "speedup": {++ "http_receipt_seconds": 1.6920417609305245,++ "driver_wall_seconds": 1.6919369713941594,++ "driver_cpu_seconds": 1.6719678016802666++ },++ "samples": {++ "baseline": [++ {++ "http_receipt_seconds": 95.46150833299998,++ "wall_s": 95.46839924599999,++ "cpu_s": 91.262433++ },++ {++ "http_receipt_seconds": 89.16425095299996,++ "wall_s": 89.17120738200003,++ "cpu_s": 88.299558++ },++ {++ "http_receipt_seconds": 90.86300797699994,++ "wall_s": 90.87042387300005,++ "cpu_s": 88.861937++ }++ ],++ "current": [++ {++ "http_receipt_seconds": 53.700215961000026,++ "wall_s": 53.70792494599999,++ "cpu_s": 53.193524000000004++ },++ {++ "http_receipt_seconds": 54.241986263,++ "wall_s": 54.24954402000003,++ "cpu_s": 53.148115++ },++ {++ "http_receipt_seconds": 53.21489614999996,++ "wall_s": 53.22215729599998,++ "cpu_s": 52.375015++ }++ ]++ },++ "unchanged_artifact_counts_ledger_and_outcome": true++ },++ "point_scoring": [++ {++ "clock_half_width_s": 10,++ "pairs": 2,++ "exact_outputs": true,++ "medians": {++ "baseline": {++ "wall_seconds": 2.222001012999982,++ "cpu_seconds": 2.2199421265,++ "peak_rss_mib": 323.892578125++ },++ "current": {++ "wall_seconds": 1.2922302594999735,++ "cpu_seconds": 1.2903656390000002,++ "peak_rss_mib": 322.8359375++ }++ },++ "speedup": {++ "wall_seconds": 1.7195085757083122,++ "cpu_seconds": 1.7203977379778939++ }++ },++ {++ "clock_half_width_s": 120,++ "pairs": 2,++ "exact_outputs": true,++ "medians": {++ "baseline": {++ "wall_seconds": 14.141562013999987,++ "cpu_seconds": 14.1370346765,++ "peak_rss_mib": 382.28125++ },++ "current": {++ "wall_seconds": 7.738493016999996,++ "cpu_seconds": 7.734289864999999,++ "peak_rss_mib": 383.873046875++ }++ },++ "speedup": {++ "wall_seconds": 1.8274309976029788,++ "cpu_seconds": 1.8278387445076707++ }++ }++ ],++ "further_integration_results": "https://github.com/1337isnot1337/DOPPLERGEIST/pull/237"++ }++}diff --cc docs/PERFORMANCE.mdindex 508d24f,3af8a95..d3324ae--- a/docs/PERFORMANCE.md+++ b/docs/PERFORMANCE.md@@@ -1,5 -1,5 +1,91 @@@# Measured pipeline performance++## Measured native computation and bounded reuse++++The implementation at [`41d0646`](https://github.com/1337isnot1337/DOPPLERGEIST/commit/41d06469935f776988e1a4f04ab386d0355b433b) completed the regional HTTP replay in a median **37.188 seconds**, compared with **62.031 seconds** for the already optimized main baseline [`fec518e5`](https://github.com/1337isnot1337/DOPPLERGEIST/commit/fec518e51f14afe8d36203e6c5e1be1277dea14e).++That is **1.668× faster**, with **40.05% less elapsed time**, across three alternating fresh pairs.++The [recorded-input CI run](https://github.com/1337isnot1337/DOPPLERGEIST/actions/runs/41685506906) passed all complete-scoring and HTTP equality gates.++The [compact measurement record](../benchmarks/results/exact-native-pipeline-20261103.json) preserves the individual samples, source pins, runtime, controls, and comparison scope.++++| Workload | Baseline wall median | Optimized wall median | Speedup |++| --- | ---: | ---: | ---: |++| Complete regional HTTP replay, three pairs | 62.031 s | 37.188 s | **1.668×** |++| Complete point scoring, ±10 s clock, two pairs | 2.164 s | 1.273 s | **1.700×** |++| Complete point scoring, ±120 s clock, two pairs | 13.858 s | 7.652 s | **1.811×** |++++HTTP baseline samples span **61.861–62.422 seconds**; optimized samples span **37.106–38.206 seconds**.++Median driver CPU time falls from **61.607 to 36.863 seconds**; it includes the verifier and its child processes.++Every pair processes the complete 3,600.1845-second recording and returns **17 ridge records, 15 independent groups, and 23 candidates**.++The decision remains `inconclusive / search_incomplete`.++++Each HTTP pair compares 20 job JSON files, three root JSON files, the logical SQLite ledger, decoded PCM, 17 CSV files, and PNG pixels.++All three pairs have zero scientific or array differences after the declared metadata normalization, with no numerical tolerance.++Each ledger contains the same 29,738 bounds, 852 records, 12 stages, and one run.++The broad point workload compares all **3,905 candidates**, including diagnostics and support records, and retains the same 100 across 16 groups.++Its worker-lifetime peak RSS changes from **381.92 to 383.83 MiB**.++Each timed broad call records **38,890 successful native ridge operations and 850 successful native acoustic operations**.++All **78 selected recorded-input regression tests pass** at this measured checkpoint.++++### Why this version is faster++++The optional acoustic extension fuses spline evaluation, Newton updates, and vector reductions while preserving polynomial arithmetic order and the global stopping rule.++The optional ridge extension preserves six IRLS iterations and the original reduction order.++Python continues to handle unsupported representations, motion diagnostics, and exceptional numerical cases.++++Repeated associations reuse validated batch ceilings within the existing 4 MiB budget for digest keys and serialized fit payloads.++A separate 8 MiB cache retains conservative, floor-independent acoustic loss evidence.++Every call still validates public inputs and applies its current ranking cutoff and group count.++The budgets cover their documented payload or evidence accounting; they are not limits on total process memory.++First-use hashing and serialization have a cost, so the complete-job measurements above determine the net benefit.++++Trajectory queries continue in one pass when they exceed their initial budget.++CPA preparation reuses receiver coordinates, per-track samples, and spatial trees across bounded chunks, then builds one compact table.++Unsupported-motion checks batch interval work while retaining endpoint behavior and failure accounting.++Detector thresholds, event coverage, search resolution, solver iterations, and scientific tolerances are unchanged.++++The native ridge implementation and narrow acoustic loss-bound cache are integrated from [PR228](https://github.com/1337isnot1337/DOPPLERGEIST/pull/228) at `2625539`.++The acoustic solver, batch-ceiling reuse, motion-support batching, one-pass queries, and CPA changes are separate contributions in [PR237](https://github.com/1337isnot1337/DOPPLERGEIST/pull/237).++Previously merged main optimizations remain in the comparison baseline.++++### Measurement controls and limits++++HTTP pairs run in baseline/current, current/baseline, and baseline/current order, with fresh processes and output directories.++Both arms share one MP3, request, operator configuration, flight index, and terrain set; both use one pinned CPU and one numerical thread.++Input restoration, index preparation, and MP3 encoding occur before timing.++Operating-system page caches are not purged.++Point scoring uses two alternating pairs and measures input loading separately.++Separate profiling runs do not contribute to timing medians.++++The HTTP job uses Python 3.12.16; the point job uses Python 3.12.15.++Both use NumPy 2.5.4, and each comparison matches the complete runtime between its baseline and optimized arms.++The HTTP input is the original MP3 encoding with SHA-256 `707083f0344823eeea7f130faec6c22b6628b8b9fea04d026915d93df9a07b15`.++The regional request spans `[-73.545, 40.865, -73.505, 40.895]` and recording-start times from `2026-09-08T20:17:20Z` to `20:17:40Z`.++It uses one search worker, 2 km coarse spacing, 500 m refinement spacing, top-K 20, and three refinement finalists.++++Install with a compatible C compiler and use the [native-backend checks and reproduction commands](#reproduce-the-optional-native-backends).++Either extension can fall back to Python, and both backends have explicit Python selectors.++Native performance and exact arithmetic controls were measured on Linux; macOS and Windows native performance remain unmeasured.++++These are computation controls on a real recording and historical observations with source-informed regional bounds and clock evidence.++They do not establish independent location accuracy, nationwide completion time, or first-time network-acquisition speedup.++Earlier measurements below retain their original commits, encodings, and runtimes.++Their absolute times cannot be compared across runners, and component speedups must not be multiplied into a whole-pipeline claim.++++### Integration confirmation++++Source [`d935180`](https://github.com/1337isnot1337/DOPPLERGEIST/commit/d93518010345a921b09722b8d7fc4ca1961c396e) incorporates later main changes through `b149d894`.++Its [complete replay](https://github.com/1337isnot1337/DOPPLERGEIST/actions/runs/41687118475) passes **78 recorded-input tests and all four explicit Python-fallback tests, with zero skips**.++This corrects the earlier fallback step's missing fixture setting, which had caused three tests to skip at `41d0646`.++All three HTTP pairs and both complete point comparisons again have exact scientific outputs and logical ledgers.++Against the same frozen baseline `fec518e5`, median HTTP time is **90.863 → 53.700 seconds**, or **1.692×**, on this separate runner.++Median driver CPU time is **88.862 → 53.148 seconds**; narrow and broad point-scoring speedups are **1.720×** and **1.827×**.++The differing absolute times illustrate why comparisons must stay within a matched run.++The [Python 3.11 and 3.14 installation checks](https://github.com/1337isnot1337/DOPPLERGEIST/actions/runs/41687129205) also pass.++The compact measurement record contains this confirmation separately from the first measured checkpoint.++Further main integration, its exact comparison baseline, and final gate results are recorded in [PR237](https://github.com/1337isnot1337/DOPPLERGEIST/pull/237).++++## Historical PR225 integration measurements++The integrated implementation completed the fresh bounded HTTP workflow in **54.176928122 seconds**, compared with **78.379028870 seconds** for baseline `aa3dff6`.That is an observed **1.44672×** speedup and **30.88%** less elapsed time in one sequential pair on the same CI runner.The [integrated measurement record](../benchmarks/results/integrated-http-20261103.json) preserves exact output comparisons and the measured source pins.@@@ -838,90 -838,3 +924,93 @@@ terrain-stage evidence, not a full-searApplying this scheduler to a saved search changes the package identity andrequires its validated checkpoint compatibility path before resuming that job.++## Reproduce the optional native backends++Installation builds the acoustic and ridge extensions when a compatible C compiler is available.+The package remains usable when either optional extension cannot build.+A source checkout used for timing must contain its own built extensions; an installed copy elsewhere does not establish native use.++```bash+. .venv/bin/activate+CC=gcc python -m pip install --editable '.[test]'+python - <<'PY'+from dopplergeist.geometry import ACOUSTIC_BACKEND+from dopplergeist.matching import RIDGE_FIT_BACKEND+print("Acoustic:", ACOUSTIC_BACKEND)+print("Ridge:", RIDGE_FIT_BACKEND)+assert ACOUSTIC_BACKEND.startswith("native-c-")+assert RIDGE_FIT_BACKEND.startswith("native-c-")+PY+```++The native acoustic solver retains polynomial evaluation order, global Newton stopping, and Python motion-support diagnostics.+The ridge extension retains the six IRLS iterations and reduction order.+Both extensions disable floating-point reassociation and contraction.+Incompatible numeric representations use the existing Python implementations.+Acoustic and scalar ridge calls also fall back for unsupported NumPy error policies.+Batched ridge arithmetic retains its existing ignored-error block and restores the caller's policy for diagnostics.+The optional ridge implementation is integrated from [PR228](https://github.com/1337isnot1337/DOPPLERGEIST/pull/228).++Set `DOPPLERGEIST_ACOUSTIC_BACKEND=python` and `DOPPLERGEIST_RIDGE_BACKEND=python` before starting a process to force both Python implementations.+The default for each selector is `auto`; invalid selector values fail explicitly.+The legacy checkpoint upgrade requires both Python backends and its original runtime and input controls.+Ordinary checkpoints include the selected native binary identities and reject an implementation mismatch.++### Recorded-input scoring comparison++Install the GitHub CLI (`gh`) before restoring the published input bundles; the restoration script uses `gh release download`.+Use a fresh output directory and preserve the baseline checkout for the entire comparison.++The commands compare the checked-out source against `fec518e5`; use source `41d0646` to repeat the native-computation table's measured optimization checkpoint.++Build the extensions in that checkout first. Another source revision or runtime produces a new comparison.+The following commands freeze the same real observations and source-informed receiver/clock workload for both implementations:++```bash+export OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 MKL_NUM_THREADS=1 NUMEXPR_NUM_THREADS=1+export PYTHONPATH=src+git worktree add --detach ../DOPPLERGEIST-perf-baseline fec518e51f14afe8d36203e6c5e1be1277dea14e+python scripts/restore_artifacts.py --bundle data-adsb-derived --bundle data-terrain+python scripts/prepare_reference_upload.py --data-root data --output benchmark-inputs+for width in 10 120; do+ python scripts/benchmark_prepared_measurements.py prepare \+ --discovery evidence/audio/w1-sensitivity-20261102/reference/discovery.json \+ --index benchmark-inputs/reference-region.sqlite \+ --clock-half-width-s "$width" --output "benchmark-inputs/point-$width.json"+ python scripts/benchmark_prepared_measurements.py compare \+ --fixture "benchmark-inputs/point-$width.json" \+ --baseline-source ../DOPPLERGEIST-perf-baseline/src --current-source src \- --repeats 3 --require-current-native --require-current-native-acoustic \++ --repeats 2 --require-current-native --require-current-native-acoustic \+ --output "results/native-scoring-$width"+done+```++The comparison alternates arm order in fresh worker processes.+It compares every candidate, diagnostic, support record, ranking, and logical retention row exactly before reporting a speedup.+Native success counters must increase inside the timed scoring call.+Input loading is reported separately, and the RSS measurement covers the worker lifetime through scoring.+- The complete-fit cache shares its existing 4 MiB serialized-payload budget with validated batch ceilings.++The complete-fit cache shares its existing 4 MiB digest-key and serialized-payload budget with validated batch ceilings.++Python object headers and dictionary bookkeeping require additional memory.+The separate screening cache permits at most 8 MiB of conservatively charged private loss evidence per scoring context.+It never retains a candidate's ranking cutoff: every call applies its current cutoff and group count.+These caches help repeated workloads; first-use hashing and serialization have a cost, so complete-job measurements decide whether they help a workload.++### Complete HTTP methodology++The `Real performance comparison` workflow also replays the complete recording through the HTTP application.+Select an exact baseline commit and enable the regional comparison.+Its three pairs run in baseline/current, current/baseline, and baseline/current order, with fresh directories and one shared MP3, request, operator configuration, index, and terrain set.+Both arms use the same pinned CPU and one numerical thread.+Input restoration, index preparation, and MP3 encoding happen before the timed arms.++Every pair must pass whole-recording intake, discovery, acquisition, search, refinement, and decision checks.+The comparison requires exact scientific JSON, logical SQLite contents, decoded audio, CSV/array values, and PNG pixels.+Only declared path, run identity, timing, and native implementation metadata are normalized; scientific floats have no tolerance.+Medians are emitted only after all pairs pass, and the individual samples remain available.+Profiling runs separately and never contributes to timing medians.++The original MP3 retains its 17-ridge/15-group control.+A different encoding requires an explicit declaration and the canonical WAV identity; it cannot inherit historical event counts or timing claims.+Both new-encoding arms must still process the complete recording, consider every group, and produce exactly equal outputs.+These regional computation controls use source-informed bounds and clock evidence.+They do not establish independent location accuracy, nationwide completion time, or a cold-cache acquisition speedup.diff --cc src/dopplergeist/search.pyindex 567f54c,c4fad38..9ef7604--- a/src/dopplergeist/search.py+++ b/src/dopplergeist/search.py@@@ -10,9 -10,10 +10,10 @@@ from scipy.spatial import cKDTrefrom .geometry import AcousticSupportError, ecef--# Most national track/receiver chunks are empty; construct their schema once.-_EMPTY_CPA_TABLE = pd.DataFrame(columns=[- "point_id", "flight_id", "emission_time", "receive_time", "distance_m", "speed_mps"])+_CPA_COLUMNS = ["point_id", "flight_id", "emission_time", "receive_time", "distance_m", "speed_mps"]+_CPA_DTYPE = np.dtype([(name, "int64" if name == "point_id" else object if name == "flight_id" else "float64")+ for name in _CPA_COLUMNS])++_EMPTY_CPA_TABLE = pd.DataFrame(columns=_CPA_COLUMNS)def cpa_table_dense(tracks, points, max_distance, c=343.0, step_s=2.0, chunk_size=256):@@@ -85,46 -87,24 +87,57 @@@ def cpa_table(tracks,points,max_distanc"""observers=ecef(points.lat.to_numpy(),points.lon.to_numpy(),points.elev_m.to_numpy())point_ids=points.point_id.to_numpy(dtype=int)- return pd.DataFrame(_cpa_rows(tracks, observers, point_ids, max_distance, c, step_s, chunk_size),- columns=_CPA_COLUMNS)++ rows = _cpa_rows(tracks, observers, point_ids, max_distance, c, step_s, chunk_size,++ _sample_cache=_sample_cache)++ return pd.DataFrame(rows, columns=_CPA_COLUMNS) if rows else _EMPTY_CPA_TABLE.copy()++- def _cpa_rows(tracks, observers, point_ids, max_distance, c=343.0, step_s=2.0, chunk_size=512):++def _cpa_rows(tracks, observers, point_ids, max_distance, c=343.0, step_s=2.0, chunk_size=512, *,++ _sample_cache=None):+ """Return the same ordered CPA records without allocating per-track tables.++ Tiled scoring already has ECEF observers and needs to isolate unsupported+ tracks. It can reuse those observers and materialize one table after the+ bounded per-track work instead of rebuilding a DataFrame for every query.+ """rows=[]for track in tracks:- prepared = _PreparedCPATrack(track, c, step_s)++ prepared = _PreparedCPATrack(track, c, step_s, _sample_cache=_sample_cache)+ rows.extend(prepared.raw_rows(observers, point_ids, max_distance, chunk_size))+ return _ordered_cpa_rows(rows, step_s)+++class _PreparedCPATrack:+ """One validated track/step, reused only across one call's receiver chunks."""+- def __init__(self, track, c, step_s):++ def __init__(self, track, c, step_s, *, _sample_cache=None):track.validate_motion_support(c)+ self.track, self.c, self.step_s = track, c, step_s- self.time = np.unique(np.r_[np.arange(track.time[0], track.time[-1], step_s), track.time[-1]])- self.position = track.position(self.time)- self.max_step = np.max(np.linalg.norm(np.diff(self.position, axis=0), axis=1))+ key = (id(track), step_s)+ sampled = None if _sample_cache is None else _sample_cache.get(key)+ if sampled is None:- t=np.unique(np.r_[np.arange(track.time[0],track.time[-1],step_s),track.time[-1]])- pos=track.position(t)- max_step=np.max(np.linalg.norm(np.diff(pos,axis=0),axis=1))++ self.time = np.unique(np.r_[np.arange(track.time[0], track.time[-1], step_s), track.time[-1]])++ self.position = track.position(self.time)++ self.max_step = np.max(np.linalg.norm(np.diff(self.position, axis=0), axis=1))+ if _sample_cache is not None:- # Retain the track too, so its object ID cannot be reused.- _sample_cache[key] = (track, t, pos, max_step)++ # Match the public wrapper's existing tuple protocol. Only++ # sampling is reused: validation and sound speed stay local.++ _sample_cache[key] = (track, self.time, self.position, self.max_step)+ else:- _, t, pos, max_step = sampled- near=np.flatnonzero(np.all((observers>=pos.min(axis=0)-max_distance)&- (observers<=pos.max(axis=0)+max_distance),axis=1))- if not len(near):continue- tree=cKDTree(pos)++ _, self.time, self.position, self.max_step = sampled+ self.lower, self.upper = self.position.min(axis=0), self.position.max(axis=0)+ self.tree = None++ def raw_rows(self, observers, point_ids, max_distance, chunk_size=512):+ rows = []+ track, t, pos, c = self.track, self.time, self.position, self.c+ near=np.flatnonzero(np.all((observers>=self.lower-max_distance)&+ (observers<=self.upper+max_distance),axis=1))+ if not len(near):+ return rows+ if self.tree is None:+ self.tree = cKDTree(pos)+ tree = self.treefor base in range(0,len(near),chunk_size):chosen=near[base:base+chunk_size]obs=observers[chosen]diff --cc tests/test_real_cpa_preparation.pyindex 3827288,0000000..e40eb88mode 100644,000000..100644--- a/tests/test_real_cpa_preparation.py+++ b/tests/test_real_cpa_preparation.py@@@ -1,85 -1,0 +1,122 @@@+"""CPA preparation reuse on unchanged archived aircraft observations."""+import json+from pathlib import Path+import unittest+from unittest.mock import patch++import numpy as np+import pandas as pd++from dopplergeist import search+from dopplergeist.geometry import AcousticSupportError, Track, ecef+from dopplergeist.tracks import _segment_velocity+++class RealCPAPreparationTests(unittest.TestCase):+ @classmethod+ def setUpClass(cls):+ cls.tracks = []+ root = Path(__file__).resolve().parents[1]+ for source in sorted((root / "research/trajectory-motion/frozen").glob("fresh-*.json")):+ frame = pd.DataFrame(json.loads(source.read_text())).sort_values("time_s")+ for number, (_, rows) in enumerate(frame.groupby((frame.time_s.diff() > 30.).cumsum())):+ if len(rows) < 3:+ continue+ velocity, _ = _segment_velocity(rows)+ cls.tracks.append(Track(f"{rows.flight_id.iloc[0]}:{number}", rows.time_s.to_numpy(),+ rows.lat.to_numpy(), rows.lon.to_numpy(), rows.alt_m.to_numpy(),+ str(rows.typecode.iloc[0]), velocity))+ cls.supported, cls.unsupported = [], []+ for track in cls.tracks:+ try:+ track.validate_motion_support()+ cls.supported.append(track)+ except AcousticSupportError:+ cls.unsupported.append(track)+ cls.long_track = next(track for track in cls.supported if track.time[-1]-track.time[0] > 800.)++ def test_one_sampling_and_tree_for_several_real_receiver_chunks(self):+ track = self.long_track+ indices = np.linspace(1, len(track.time)-2, 24, dtype=int)+ observers = ecef(track.lat[indices], track.lon[indices], np.zeros(len(indices)))+ point_ids = np.arange(len(indices))+ for step in (np.float32(2), np.float64(2), np.longdouble(2)):+ chunks = [(observers[first:first+4], point_ids[first:first+4]) for first in range(0, len(indices), 4)]+ expected = [search._cpa_rows([track], points, ids, 20000., 343., step) for points, ids in chunks]+ with patch.object(track, "position", wraps=track.position) as position, \+ patch.object(search, "cKDTree", wraps=search.cKDTree) as tree:+ prepared = search._PreparedCPATrack(track, 343., step)+ actual = [search._ordered_cpa_rows(prepared.raw_rows(points, ids, 20000.), step)+ for points, ids in chunks]+ self.assertEqual(expected, actual)+ self.assertGreater(sum(map(len, actual)), 0)+ self.assertEqual(tree.call_count, 1)+ sampled = [call for call in position.call_args_list+ if np.asarray(call.args[0]).ndim == 1 and len(np.asarray(call.args[0])) > 3]+ self.assertEqual(len(sampled), 1)++ def test_tree_stays_lazy_for_distant_recorded_receiver(self):+ track = self.long_track+ distant = next(other for other in self.supported if abs(other.lon[0]-track.lon[0]) > 3.)+ far = ecef(distant.lat[:1], distant.lon[:1], np.zeros(1))+ midpoint = len(track.time)//2+ near = ecef(track.lat[midpoint:midpoint+1], track.lon[midpoint:midpoint+1], np.zeros(1))+ prepared = search._PreparedCPATrack(track, 343., 2.)+ self.assertIsNone(prepared.tree)+ self.assertEqual(prepared.raw_rows(far, np.array([0]), 20000.), [])+ self.assertIsNone(prepared.tree)+ self.assertTrue(prepared.raw_rows(near, np.array([1]), 20000.))+ tree = prepared.tree+ self.assertIsNotNone(tree)+ self.assertEqual(prepared.raw_rows(far, np.array([2]), 20000.), [])+ self.assertIs(prepared.tree, tree)++ def test_unsupported_motion_keeps_original_error(self):+ self.assertTrue(self.unsupported)+ for track in self.unsupported:+ with self.assertRaises(AcousticSupportError) as direct:+ track.validate_motion_support()+ with self.assertRaises(AcousticSupportError) as prepared:+ search._PreparedCPATrack(track, 343., 2.)+ self.assertEqual(vars(direct.exception), vars(prepared.exception))+++ def test_public_sample_cache_preserves_chunks_and_sound_speed_validation(self):++ track = self.long_track++ indices = np.linspace(1, len(track.time)-2, 24, dtype=int)++ points = pd.DataFrame({"point_id": np.arange(len(indices)), "lat": track.lat[indices],++ "lon": track.lon[indices], "elev_m": np.zeros(len(indices))})++ expected = search.cpa_table([track], points, 20000.)++ expected_changed_c = search.cpa_table([track], points, 20000., c=350.)++ with self.assertRaises(AcousticSupportError) as direct:++ search.cpa_table([track], points, 20000., c=0.)++ cache = {}++ with patch.object(track, "position", wraps=track.position) as position, \++ patch.object(track, "validate_motion_support", wraps=track.validate_motion_support) as validate:++ chunks = [search.cpa_table([track], points.iloc[first:first+4], 20000., _sample_cache=cache)++ for first in range(0, len(points), 4)]++ changed_c = search.cpa_table([track], points, 20000., c=350., _sample_cache=cache)++ with self.assertRaises(AcousticSupportError) as cached:++ search.cpa_table([track], points, 20000., c=0., _sample_cache=cache)++ actual = pd.concat(chunks, ignore_index=True).sort_values(++ ["point_id", "flight_id", "emission_time"]).reset_index(drop=True)++ pd.testing.assert_frame_equal(actual, expected, check_exact=True)++ pd.testing.assert_frame_equal(changed_c, expected_changed_c, check_exact=True)++ self.assertGreater(len(actual), 0)++ self.assertEqual(vars(cached.exception), vars(direct.exception))++ self.assertEqual([call.args[0] for call in validate.call_args_list], [343.] * len(chunks) + [350., 0.])++ sampled = [call for call in position.call_args_list++ if np.asarray(call.args[0]).ndim == 1 and len(np.asarray(call.args[0])) > 3]++ self.assertEqual(len(sampled), 1)++ self.assertEqual(set(cache), {(id(track), 2.)})++ stored = cache[(id(track), 2.)]++ self.assertIs(type(stored), tuple)++ self.assertEqual(len(stored), 4)++ self.assertIs(stored[0], track)++ expected_step = search.cpa_table([track], points, 20000., step_s=3.)++ changed_step = search.cpa_table([track], points, 20000., step_s=3., _sample_cache=cache)++ pd.testing.assert_frame_equal(changed_step, expected_step, check_exact=True)++ self.assertEqual(set(cache), {(id(track), 2.), (id(track), 3.)})++++if __name__ == "__main__":+ unittest.main()