Miriam Gershenson | 6cb19a8 | 2018-03-23 14:27:20 | [diff] [blame] | 1 | # Host Resolution |
| 2 | |
| 3 | This document is a brief overview of how host resolution works in the Chrome |
| 4 | network stack. |
| 5 | |
| 6 | The stack includes two different implementations: the "system" or "platform" |
| 7 | resolver, and the "async" or "built-in" resolver. The higher layers are shared |
| 8 | between the implementations, and the lower layers are implemented separately. |
| 9 | |
| 10 | ## Shared layers |
| 11 | |
| 12 | ### Host resolver |
| 13 | |
| 14 | The HostResolverImpl is the main interface between DNS and the rest of the |
| 15 | network stack. It checks the HostCache, checks if there is an already running |
| 16 | Job, and schedules a new Job if there isn't one in progress. |
| 17 | |
| 18 | Data collected at this layer: |
| 19 | * "Net.DNS.TotalTime" (recommended for DNS experiments) |
| 20 | * "Net.DNS.TotalTimeNotCached" |
| 21 | |
| 22 | ### Job |
| 23 | |
| 24 | The 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 |
| 26 | starts a task depending on which implementation should be used. If a DnsTask |
| 27 | fails, it retries using a ProcTask. |
| 28 | |
| 29 | Data 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 | |
| 40 | The entry point for the system resolver is HostResolverImpl::ProcTask. The task |
Gabriel Charette | 52fa3ae | 2019-04-15 21:44:37 | [diff] [blame] | 41 | runs almost entirely on ThreadPool. Its main implementation is in |
Miriam Gershenson | 6cb19a8 | 2018-03-23 14:27:20 | [diff] [blame] | 42 | SystemHostResolverProc. Other implementations of HostResolverProc can be swapped |
| 43 | in for testing. |
| 44 | |
| 45 | Data collected at this layer: |
| 46 | * "Net.DNS.ProcTask.SuccessTime" |
| 47 | * "Net.DNS.ProcTask.FailureTime" |
| 48 | * "Net.OSErrorsForGetaddrinfo*" |
| 49 | |
| 50 | ### Attempt |
| 51 | |
| 52 | Attempts in the system resolver are not a separate class. They're implemented as |
Gabriel Charette | 52fa3ae | 2019-04-15 21:44:37 | [diff] [blame] | 53 | separate tasks posted to ThreadPool. |
Miriam Gershenson | 6cb19a8 | 2018-03-23 14:27:20 | [diff] [blame] | 54 | |
| 55 | Data 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 | |
| 69 | The entry point for the async resolver is HostResolverImpl::DnsTask. DnsTask |
| 70 | starts one DnsTransaction for each lookup needed, which can be one for a single |
| 71 | address family or two when both A and AAAA are needed. |
| 72 | |
| 73 | Data 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 | |
| 82 | The main implementation of the async resolver is in the DnsTransaction. Each |
| 83 | transaction represents a single query, which might be tried multiple times or in |
| 84 | different ways. |
| 85 | |
Miriam Gershenson | 6cb19a8 | 2018-03-23 14:27:20 | [diff] [blame] | 86 | ### Attempt |
| 87 | |
| 88 | Attempts in the async resolver are an explicit layer, implemented by subclasses |
| 89 | of DnsAttempt. In most cases, DnsUDPAttempt is used. DnsTCPAttempt is used |
| 90 | instead when the server requests it. DnsHTTPAttempt is experimental. |