24 January 2018

Windows 10: DNS Client load CPU in case of big hosts file

After installing Fall Creators Update (KB4058043, KB4057247, KB4055237, KB4055994) on Windows 10 Pro 1709 (16299.125) I noticed a long delay in the opening of websites.

Symptoms

  • The DNS Client service load is about 25% CPU.
  • You can't open any website and get access to the internet at all for several minutes.

Investigation

  • The hosts file size is 1185 Kb (43211 lines).
  • In the Event Viewer appears an error 7011 from Service Control Manager - "A timeout (30000 milliseconds) was reached while waiting for a transaction response from the Dnscache service".
  • The DNS Client service load ~25% CPU and 20,7 MB RAM.

  • DNS lookup works, but in the same time ping to any IP doesn't, just freezes.

  • Process Monitor shows that svchost.exe reads the hosts file for a "long" time.

Tests

After a while I decided to go back to this problem and check how long does it take for the "DNS Client" service to read the hosts file.


Number of lines (with comments) Number of real lines (only domains) hosts file size, bytes Windows 10 Home 1709 (16299.251) Windows 10 Pro 1803 (17134.137)
Version of svchosts.exe file 10.0.16299.15 10.0.17134.1
Freeze Yes Yes
hosts #1 (1000 lines) 1 000 1 000 28 888 <1 s. <1 s.
hosts #2 (43k lines with comments) 43 211 38 487 1 213 150 ~32 s. ~58 s.
hosts #3 (#2 compressed) 38 487 38 487 1 090 350 ~26 s. ~48 s.

Workaround

  • Use short hosts file (up to 1000 lines).
  • Compress hosts file:
    • Remove all comments.
    • Replace "127.0.0.1" (loopback Internet protocol (IP) address) to "0.0.0.0" (non-routable meta-address).

Resolution

No comments:

Post a Comment