blob: a151c639167a3487c9f6754b89e8df73d5691220 [file] [log] [blame] [view]
Miriam Gershenson6cb19a82018-03-23 14:27:201# Host Resolution
2
3This document is a brief overview of how host resolution works in the Chrome
4network stack.
5
6The stack includes two different implementations: the "system" or "platform"
7resolver, and the "async" or "built-in" resolver. The higher layers are shared
8between the implementations, and the lower layers are implemented separately.
9
10## Shared layers
11
12### Host resolver
13
14The HostResolverImpl is the main interface between DNS and the rest of the
15network stack. It checks the HostCache, checks if there is an already running
16Job, and schedules a new Job if there isn't one in progress.
17
18Data collected at this layer:
19* "Net.DNS.TotalTime" (recommended for DNS experiments)
20* "Net.DNS.TotalTimeNotCached"
21
22### Job
23
24The HostResolverImpl::Job represents a single DNS resolution from the network
25(or in some cases the OS's DNS cache, which Chrome doesn't know about). It
26starts a task depending on which implementation should be used. If a DnsTask
27fails, it retries using a ProcTask.
28
29Data collected at this layer:
30* "Net.DNS.ResolveSuccessTime" (also by address family)
31* "Net.DNS.ResolveFailureTime" (also by address family)
32* "Net.DNS.ResolveCategory"
33* "Net.DNS.ResolveError.Fast"
34* "Net.DNS.ResolveError.Slow"
35
36## System resolver
37
38### Task
39
40The entry point for the system resolver is HostResolverImpl::ProcTask. The task
Gabriel Charette52fa3ae2019-04-15 21:44:3741runs almost entirely on ThreadPool. Its main implementation is in
Miriam Gershenson6cb19a82018-03-23 14:27:2042SystemHostResolverProc. Other implementations of HostResolverProc can be swapped
43in for testing.
44
45Data collected at this layer:
46* "Net.DNS.ProcTask.SuccessTime"
47* "Net.DNS.ProcTask.FailureTime"
48* "Net.OSErrorsForGetaddrinfo*"
49
50### Attempt
51
52Attempts in the system resolver are not a separate class. They're implemented as
Gabriel Charette52fa3ae2019-04-15 21:44:3753separate tasks posted to ThreadPool.
Miriam Gershenson6cb19a82018-03-23 14:27:2054
55Data collected at this layer:
56* "DNS.AttemptFirstSuccess"
57* "DNS.AttemptFirstFailure"
58* "DNS.AttemptSuccess"
59* "DNS.AttemptFailure"
60* "DNS.AttemptDiscarded"
61* "DNS.AttemptCancelled"
62* "DNS.AttemptSuccessDuration"
63* "DNS.AttemptFailDuration"
64
65## Async resolver
66
67### Task
68
69The entry point for the async resolver is HostResolverImpl::DnsTask. DnsTask
70starts one DnsTransaction for each lookup needed, which can be one for a single
71address family or two when both A and AAAA are needed.
72
73Data collected at this layer:
74* "Net.DNS.DnsTask.SuccessTime"
75* "Net.DNS.DnsTask.FailureTime"
76* "Net.DNS.DnsTask.ErrorBeforeFallback.Fast"
77* "Net.DNS.DnsTask.ErrorBeforeFallback.Slow"
78* "Net.DNS.DnsTask.Errors"
79
80### Transaction
81
82The main implementation of the async resolver is in the DnsTransaction. Each
83transaction represents a single query, which might be tried multiple times or in
84different ways.
85
Miriam Gershenson6cb19a82018-03-23 14:27:2086### Attempt
87
88Attempts in the async resolver are an explicit layer, implemented by subclasses
89of DnsAttempt. In most cases, DnsUDPAttempt is used. DnsTCPAttempt is used
90instead when the server requests it. DnsHTTPAttempt is experimental.