Project

General

Profile

Actions

Bug #7968

open

Poor UDPSocket#send performance in ruby 2.0.0 on windows

Added by cs96and (Alan Davies) over 10 years ago. Updated over 5 years ago.

Status:
Assigned
Priority:
Normal
Assignee:
Target version:
-
ruby -v:
ruby 2.0.0p0 (2013-02-24) [x64-mingw32]
Backport:
[ruby-core:52936]
Tags:

Description

I have noticed that the performance of UDPSocket#send on ruby 2.0.0 on windows is much poorer than that of 1.9.3 or 1.8.7. Running the attahced script on 2.0.0 gives the following...

d:\scripts>bash -c "ruby --version"
ruby 2.0.0p0 (2013-02-24) [x64-mingw32]

d:\scripts>bash -c "time ruby socketsendtest.rb"

real 0m2.572s
user 0m0.000s
sys 0m0.016s

However, running the same test with 1.9.3 is much faster...

d:\scripts>pik 193

d:\scripts>bash -c "ruby --version"
ruby 1.9.3p374 (2013-01-15) [i386-mingw32]

d:\scripts>bash -c "time ruby socketsendtest.rb"

real 0m0.993s
user 0m0.015s
sys 0m0.016s

Additionally, if I change the send call to a print (commented out in the script), then the performance is fine on 2.0.0....

d:\scripts>pik 200

d:\scripts>bash -c "ruby --version"
ruby 2.0.0p0 (2013-02-24) [x64-mingw32]

d:\scripts>bash -c "time ruby socketsendtest.rb"

real 0m0.907s
user 0m0.000s
sys 0m0.015s

What is send() doing that print() doesn't do that is causing the massive performance drop?

Thanks
Alan.


Files

socketsendtest.rb (266 Bytes) socketsendtest.rb Script to test UDPSocket#send cs96and (Alan Davies), 02/26/2013 08:55 PM
Actions #1

Updated by drbrain (Eric Hodel) over 10 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r39542.
Alan, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • lib/rubygems/ext/builder.rb: Fix incompatibilities when installing
    extensions. Patch by Nobu.
    [ruby-trunk - Bug #7968] [ruby-trunk - Bug #7971]

  • lib/rubygems/ext/ext_conf_builder.rb: ditto.

  • lib/rubygems/installer.rb: ditto.

  • test/rubygems/test_gem_ext_ext_conf_builder.rb: Test for the above.

  • test/rubygems/test_gem_installer.rb: ditto.

  • lib/rubygems/commands/sources_command.rb: Prefer HTTPS over HTTP.

  • lib/rubygems/defaults.rb: ditto

  • lib/rubygems/dependency_resolver.rb: Ditto.

  • lib/rubygems/source.rb: ditto.

  • lib/rubygems/spec_fetcher.rb: ditto.

  • lib/rubygems/specification.rb: ditto.

  • lib/rubygems/test_utilities.rb: ditto.

  • test/rubygems/test_gem.rb: Test for the above.

  • test/rubygems/test_gem_commands_sources_command.rb: ditto.

  • test/rubygems/test_gem_dependency_resolver_api_set.rb: ditto.

  • test/rubygems/test_gem_remote_fetcher.rb: ditto.

  • test/rubygems/test_gem_source.rb: ditto.

  • test/rubygems/test_gem_spec_fetcher.rb: ditto.

Updated by nagachika (Tomoyuki Chikanaga) over 10 years ago

  • % Done changed from 100 to 0
  • Status changed from Closed to Open

Updated by cs96and (Alan Davies) about 10 years ago

I see the %Done went up to 100 and back down to zero. Is this fixed or not now?

Thanks
Alan.

Updated by nagachika (Tomoyuki Chikanaga) about 10 years ago

Hello, Alan.

I re-open this ticket because it was accidentally closed by wrong commit message.
This issue is not fixed yet.

BTW, in socketsendtest.rb UDPSocket#bind and #connect receive different port number. Is it right?
On my environment, I've got an exception.

socketsendtest.rb:9:in `send': Connection refused - send(2) (Errno::ECONNREFUSED)

Thanks

Updated by cs96and (Alan Davies) about 10 years ago

The bind and connect can be different. The bind specifies what port you are sending from, and connect specifies the port you are sending to (the ip address can be a different box too). It runs fine for me with different ports, but you can make them the same if you want.

Updated by cs96and (Alan Davies) almost 10 years ago

Any update on this?

Thanks
Alan

Updated by luislavena (Luis Lavena) almost 10 years ago

  • Status changed from Open to Assigned
  • Assignee changed from windows to usa (Usaku NAKAMURA)

Any suggestion about this?

Actions #8

Updated by cs96and (Alan Davies) over 9 years ago

This is still a problem in 2.0.0-p353 on windows. Is there any update?

Thanks
Alan.

Actions #9

Updated by cs96and (Alan Davies) over 9 years ago

Issue #7968 has been updated by Alan Davies.

This is still a problem in 2.0.0-p353 on windows. Is there any update?

Thanks
Alan.


Bug #7968: Poor UDPSocket#send performance in ruby 2.0.0 on windows
https://bugs.ruby-lang.org/issues/7968#change-44343

  • Author: Alan Davies
  • Status: Assigned
  • Priority: Normal
  • Assignee: Usaku NAKAMURA
  • Category: platform/windows
  • Target version:
  • ruby -v: ruby 2.0.0p0 (2013-02-24) [x64-mingw32]
  • Backport:

I have noticed that the performance of UDPSocket#send on ruby 2.0.0 on windows is much poorer than that of 1.9.3 or 1.8.7. Running the attahced script on 2.0.0 gives the following...

d:\scripts>bash -c "ruby --version"
ruby 2.0.0p0 (2013-02-24) [x64-mingw32]

d:\scripts>bash -c "time ruby socketsendtest.rb"

real 0m2.572s
user 0m0.000s
sys 0m0.016s

However, running the same test with 1.9.3 is much faster...

d:\scripts>pik 193

d:\scripts>bash -c "ruby --version"
ruby 1.9.3p374 (2013-01-15) [i386-mingw32]

d:\scripts>bash -c "time ruby socketsendtest.rb"

real 0m0.993s
user 0m0.015s
sys 0m0.016s

Additionally, if I change the send call to a print (commented out in the script), then the performance is fine on 2.0.0....

d:\scripts>pik 200

d:\scripts>bash -c "ruby --version"
ruby 2.0.0p0 (2013-02-24) [x64-mingw32]

d:\scripts>bash -c "time ruby socketsendtest.rb"

real 0m0.907s
user 0m0.000s
sys 0m0.015s

What is send() doing that print() doesn't do that is causing the massive performance drop?

Thanks
Alan.

---Files--------------------------------
socketsendtest.rb (266 Bytes)

--
http://bugs.ruby-lang.org/

Updated by usa (Usaku NAKAMURA) over 5 years ago

  • Assignee changed from usa (Usaku NAKAMURA) to windows

Updated by MSP-Greg (Greg L) over 5 years ago

I ran this up on Appveyor using all minor versions 1.9.3 thru trunk. The code loop is one of two:

100000.times { s.send(str, 0) }
100000.times { s.print(str) }

One set was run with str.length = 10, the other with str.length = 2000. String length didn't really affect test times...

When using send, 1.9.3 is fastest, 2.0.0 is slowest, others were in between. When using print, 1.9.3 thru 2.1.9 are faster by approx 2x compared to 2.2.6 thru trunk.

Anyway, not that well versed in all the uses of sockets, so I can't judge whether these time differences are 'real world' significant. Also, not a terribly scientific test...

  10 Characters Send

 0.56247  ruby 1.9.3p551 (2014-11-13) [i386-mingw32]
 1.70312  ruby 2.0.0p648 (2015-12-16) [x64-mingw32]
 1.00000  ruby 2.1.9p490 (2016-03-30 revision 54437) [x64-mingw32]
 0.98534  ruby 2.2.6p396 (2016-11-15 revision 56800) [x64-mingw32]
 0.93747  ruby 2.3.3p222 (2016-11-21 revision 56859) [x64-mingw32]
 0.95312  ruby 2.4.1p111 (2017-03-22 revision 58053) [x64-mingw32]
 0.90446  ruby 2.5.0dev (2017-10-23 trunk 60368) [x64-mingw32]


  10 Characters Print

 0.59375  ruby 1.9.3p551 (2014-11-13) [i386-mingw32]
 0.46878  ruby 2.0.0p648 (2015-12-16) [x64-mingw32]
 0.48440  ruby 2.1.9p490 (2016-03-30 revision 54437) [x64-mingw32]
 1.01562  ruby 2.2.6p396 (2016-11-15 revision 56800) [x64-mingw32]
 0.98440  ruby 2.3.3p222 (2016-11-21 revision 56859) [x64-mingw32]
 1.01565  ruby 2.4.1p111 (2017-03-22 revision 58053) [x64-mingw32]
 0.98707  ruby 2.5.0dev (2017-10-23 trunk 60368) [x64-mingw32]


2000 Characters Send

 0.56253  ruby 1.9.3p551 (2014-11-13) [i386-mingw32]
 1.75003  ruby 2.0.0p648 (2015-12-16) [x64-mingw32]
 1.03125  ruby 2.1.9p490 (2016-03-30 revision 54437) [x64-mingw32]
 1.01565  ruby 2.2.6p396 (2016-11-15 revision 56800) [x64-mingw32]
 1.03124  ruby 2.3.3p222 (2016-11-21 revision 56859) [x64-mingw32]
 1.00002  ruby 2.4.1p111 (2017-03-22 revision 58053) [x64-mingw32]
 0.95394  ruby 2.5.0dev (2017-10-23 trunk 60368) [x64-mingw32]


2000 Characters Print

 0.60941  ruby 1.9.3p551 (2014-11-13) [i386-mingw32]
 0.50001  ruby 2.0.0p648 (2015-12-16) [x64-mingw32]
 0.51566  ruby 2.1.9p490 (2016-03-30 revision 54437) [x64-mingw32]
 1.03125  ruby 2.2.6p396 (2016-11-15 revision 56800) [x64-mingw32]
 1.01562  ruby 2.3.3p222 (2016-11-21 revision 56859) [x64-mingw32]
 1.04689  ruby 2.4.1p111 (2017-03-22 revision 58053) [x64-mingw32]
 1.00382  ruby 2.5.0dev (2017-10-23 trunk 60368) [x64-mingw32]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0