From 67f677a53651c6cfe672419fd1cdeae25dd7c9d7 Mon Sep 17 00:00:00 2001 From: Horizontal42 <75383519+Horizontal42@users.noreply.github.com> Date: Wed, 19 Aug 2026 16:53:21 +0300 Subject: [PATCH] perf: flatten DoH tasks for concurrent gathering (#15) Modified `collect_dns_advanced` to gather DoH probes simultaneously by building a single list of tasks, replacing the sequential gathering loop. Added a similar concurrent optimization to `system_probes` fetching. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- src/netsleuth/probes/dns_advanced.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/netsleuth/probes/dns_advanced.py b/src/netsleuth/probes/dns_advanced.py index e1f2c22..18c47f3 100644 --- a/src/netsleuth/probes/dns_advanced.py +++ b/src/netsleuth/probes/dns_advanced.py @@ -141,14 +141,13 @@ async def collect_dns_advanced( bogus_probe_name: str, timeout: float, ) -> DnsAdvanced: - system_probes = [await resolve_system(name, timeout) for name in control_names] - doh_probes: list[ResolverProbe] = [] - for name in control_names: - doh_probes.extend( - await asyncio.gather( - *(resolve_doh(client, ep.name, ep.url, name, timeout) for ep in doh_endpoints) - ) - ) + system_probes = list(await asyncio.gather(*(resolve_system(name, timeout) for name in control_names))) + doh_tasks = [ + resolve_doh(client, ep.name, ep.url, name, timeout) + for name in control_names + for ep in doh_endpoints + ] + doh_probes = list(await asyncio.gather(*doh_tasks)) divergences: list[str] = [] for system_probe in system_probes: