rubyinstaller2: Windows Ruby 3.1 net/http IPv6 HTTP(S) requests are much slower than Ruby 3.0

What problems are you experiencing?

  • net/http requests using IPv6 are significantly slower on Ruby 3.1 than on previous versions.
  • The requests ultimately do succeed, if one waits about a minute or so.
  • Issue affects IPv6 on both HTTP and HTTPS.
  • URLs which only support IPv4 (no IPv6) are fast. See here for example IPv4-only URLs: https://whynoipv6.com/

Steps to reproduce

require 'net/http'

def do_request(url)
  uri = URI(url)
  Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
    request = Net::HTTP::Get.new uri
    response = http.request request # <-- very slow for IPv6
  end
end

do_request('https://www.google.com') # <-- very slow for IPv6
do_request('https://global.jd.com') # <-- fast for IPv4

What’s the output from ridk version?

---
ruby:
  path: C:/ruby31
  version: 3.1.1
  platform: x64-mingw-ucrt
  cc: gcc.exe (Rev9, Built by MSYS2 project) 11.2.0
ruby_installer:
  package_version: 3.1.1-1
  git_commit: d9d39f1
msys2:
  path: C:\ruby31\msys64
cc: gcc (Rev10, Built by MSYS2 project) 11.2.0
sh: GNU bash, version 5.1.16(1)-release (x86_64-pc-msys)
os: Microsoft Windows [Version 10.0.22000.556]

Original Ticket: Rubgems is slow on Ruby 3.1

Installed RubyInstaller 3.1.1-1. Running gem install and bundle install seems noticeably slower than on Ruby 3.0. Even gem update --system is very slow; takes several minutes before any log lines print at all.

Doing gem update --system (update to rubygems-3.3.9) doesn’t seem to make any difference.

I ran some basic code benchmarks on irb and there wasn’t a major performance difference between the two versions.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 26 (6 by maintainers)

Most upvoted comments

And here is the change that did it: https://github.com/ruby/net-http/pull/10

IDK. With a network (including ISP) fully supporting IPv6, there aren’t issues. But, maybe the timeouts in http are a bit long for ‘modern day’ networks?

@open_timeout = 60
@read_timeout = 60
@write_timeout = 60