Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: imprve default host for windows, docker and wsl #126

Merged
merged 3 commits into from
Sep 14, 2023
Merged

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Sep 14, 2023

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Since we had defaulted the host from anyhost to local, there had been several performance issues often either related to the ipv4/ipv6 dual stack or isolated envs (docker and WSL)

With #119 listen changed to prefer ipv4 stack 127.0.0.1 for Windows and WSL, however, it introduced performance regressions for Windows users when users type in localhost in the browser (it takes time from OS to first try ::1 as ipv6 localhost and falling back to 127.0.0.1).

This PR tries to make behavior more reasonable:

  • For Windows, same as MacOS and Linux listen on. My tests showed localhost perfectly works fast in different scenarios
  • For wsl and docker, always use "" (anyhost). These are by default isolated environments and need to be exposed by their runtime. Listening on all available interfaces makes it faster.
  • For invalid hostnames, prefer dual stack by default as fallback

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codecov
Copy link

codecov bot commented Sep 14, 2023

Codecov Report

Merging #126 (fd57374) into main (c37be8a) will increase coverage by 1.28%.
The diff coverage is 75.00%.

@@            Coverage Diff             @@
##             main     #126      +/-   ##
==========================================
+ Coverage   58.25%   59.54%   +1.28%     
==========================================
  Files          12       12              
  Lines        1490     1493       +3     
  Branches      138      143       +5     
==========================================
+ Hits          868      889      +21     
+ Misses        622      604      -18     
Files Changed Coverage Ξ”
src/_utils.ts 59.58% <60.00%> (+0.27%) ⬆️
src/listen.ts 82.88% <100.00%> (+0.11%) ⬆️

... and 1 file with indirect coverage changes

@pi0 pi0 merged commit 4d43b30 into main Sep 14, 2023
4 checks passed
@pi0 pi0 deleted the perf/default-host branch September 14, 2023 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant