Project

General

Profile

Actions

Bug #2721

closed

OpenSSL::Random.random_bytes(1) is very slow the first time on Windows

Added by ghazel (Greg Hazel) about 14 years ago. Updated about 13 years ago.

Status:
Third Party's Issue
Assignee:
-
Target version:
-
ruby -v:
ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32]
Backport:
[ruby-core:28100]

Description

=begin
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.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0