rails / sdoc

Standalone sdoc generator
http://api.rubyonrails.org/
Other
820 stars 131 forks source link

Fix performance regression due to git calls #363

Closed jonathanhefner closed 8 months ago

jonathanhefner commented 8 months ago

In d08ca4d758f2633b9a2a49a045d56d4856c2e5e4, an isolated scope was created for each rendered file. That inadvertently reset memoized values from git calls for each file, causing a performance regression.

This commit fixes the regression by memoizing the values globally.

With d08ca4d758f2633b9a2a49a045d56d4856c2e5e4~1 (444c4a46211d305353485f21012c3c242104b0e4):

  $ time bundle exec rake test:rails
  real  0m31.567s
  user  0m31.159s
  sys 0m0.394s

With d08ca4d758f2633b9a2a49a045d56d4856c2e5e4:

  $ time bundle exec rake test:rails
  real  1m11.195s
  user  1m2.671s
  sys 0m8.811s

With d08ca4d758f2633b9a2a49a045d56d4856c2e5e4 + this commit (retrofitted):

  $ time bundle exec rake test:rails
  real  0m26.155s
  user  0m25.796s
  sys 0m0.331s

With main:

  $ time bundle exec rake test:rails
  real  1m16.000s
  user  1m7.478s
  sys 0m8.818s

With main + this commit:

  $ time bundle exec rake test:rails
  real  0m29.964s
  user  0m29.562s
  sys 0m0.399s

Fixes #361.

p8 commented 8 months ago

Thanks @jonathanhefner !