Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Conversation

@rtomayko
Copy link

I've been profiling boot time for some scripts that are short-lived / high throughput and noticed that requiring the openssl lib (brought in via statsd.rb) can add a pretty massive 30ms user+sys cpu overhead:

Thread ID: 69933375328960
Fiber ID: 69933379015820
Total: 0.049605
Sort by: self_time

 %self      total      self      wait     child     calls  name
 12.78      0.008     0.006     0.000     0.002        1   RequireProf#require:openssl.so 
  6.11      0.005     0.003     0.000     0.002        1   RequireProf#require:socket 
  6.10      0.003     0.003     0.000     0.000        1   RequireProf#require:zlib 
  5.76      0.030     0.003     0.000     0.027        2   RequireProf#require:openssl 
  5.61      0.003     0.003     0.000     0.000        1   RequireProf#require:date_core 
  5.44      0.003     0.003     0.000     0.000        1   RequireProf#require:stringio 
  5.18      0.008     0.003     0.000     0.006        1   RequireProf#require:time 
  4.97      0.002     0.002     0.000     0.000        1   RequireProf#require:fcntl 
  4.48      0.005     0.002     0.000     0.003        1   RequireProf#require:openssl/config 
  4.22      0.002     0.002     0.000     0.000        1   RequireProf#require:socket.so 
  4.01      0.002     0.002     0.000     0.000        1   RequireProf#require:openssl/x509 
  3.88      0.002     0.002     0.000     0.000        1   RequireProf#require:openssl/buffering 
  3.85      0.007     0.002     0.000     0.005        1   RequireProf#require:openssl/ssl 
  3.61      0.003     0.002     0.000     0.001        1   RequireProf#require:securerandom 
  2.99      0.006     0.001     0.000     0.004        1   RequireProf#require:date 
  2.94      0.002     0.001     0.000     0.000        1   RequireProf#require:openssl/digest 
  2.93      0.002     0.001     0.000     0.000        1   RequireProf#require:openssl/cipher 
  2.87      0.001     0.001     0.000     0.000        1   RequireProf#require:digest.so 
  2.80      0.001     0.001     0.000     0.000        1   RequireProf#require:openssl/bn 
  2.53      0.001     0.001     0.000     0.000        1   RequireProf#require:date/format 
  2.45      0.050     0.001     0.000     0.048        1   RequireProf#require:statsd 
... snip everything < 1ms ...

This PR avoids loading the openssl and securerandom libs unless a signing key was provided. I've also removed the 'time' require. The core Time class has Time.now built in. Explicitly requiring 'time' brings in a bunch of formatting functions like Time#iso8601, stuff we don't here.

/cc @jssjr, @tmm1, @vmg, @github/perf

Time.now is built in. Loading the time library adds some stuff like
Time#iso8601 but doesn't seem to be used here.
@vmg
Copy link

vmg commented Mar 31, 2015

👍 Legit

@jssjr
Copy link

jssjr commented Apr 1, 2015

👍

@dbussink
Copy link

dbussink commented Apr 1, 2015

🚢

rtomayko added a commit that referenced this pull request Apr 1, 2015
Avoid loading openssl + securerandom unless needed
@rtomayko rtomayko merged commit b47de77 into master Apr 1, 2015
@aroben aroben deleted the avoid-openssl branch May 4, 2015 15:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants