From: Greg Hazel Date: 2010-02-08T15:36:00+09:00 Subject: [ruby-core:28100] [Bug #2721] OpenSSL::Random.random_bytes(1) is very slow the first time on Windows Bug #2721: OpenSSL::Random.random_bytes(1) is very slow the first time on Windows http://redmine.ruby-lang.org/issues/show/2721 Author: Greg Hazel Status: Open, Priority: Normal ruby -v: ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32] This seems to be true across 1.8.6, 1.8.7 and even 1.9.1 compiled with either MSVC6 or mingw. The first call to OpenSSL::Random.random_bytes for any number of bytes is very slow, proportional to something like the amount of code loaded already. On my machine, the first call in a fresh irb session takes about 2 seconds. Running something like this: 10000.times do |i| eval("class SomeClass#{i}; end;") end increases the time for the first call to random_bytes to 5 seconds. With a fresh Rails script/console, the first call takes about 30 seconds. Inside the first Rails request, it takes 80 seconds. Calling the function as soon as possible allows me to spend only 2 seconds and not 80 later, but this seems like a very fixable thing. ---------------------------------------- http://redmine.ruby-lang.org