Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix performance regression due to git calls #363

Merged

Conversation

jonathanhefner
Copy link
Member

In d08ca4d, 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 d08ca4d~1 (444c4a4):

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

With d08ca4d:

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

With d08ca4d + 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.

In d08ca4d, 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 d08ca4d~1 (444c4a4):

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

With d08ca4d:

  ```console
  $ time bundle exec rake test:rails
  real  1m11.195s
  user  1m2.671s
  sys 0m8.811s
  ```
With d08ca4d + this commit (retrofitted):

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

With `main`:

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

With `main` + this commit:

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

Fixes rails#361.
@jonathanhefner jonathanhefner merged commit 07df49f into rails:main Jan 17, 2024
10 checks passed
@p8
Copy link
Member

p8 commented Jan 18, 2024

Thanks @jonathanhefner !

p8 added a commit to p8/rails that referenced this pull request Jan 22, 2024
The latest version of SDoc fixes a performance regression.
This version is at least twice as fast.
rails/sdoc#363
viralpraxis pushed a commit to viralpraxis/rails that referenced this pull request Mar 24, 2024
The latest version of SDoc fixes a performance regression.
This version is at least twice as fast.
rails/sdoc#363
fractaledmind pushed a commit to fractaledmind/rails that referenced this pull request May 13, 2024
The latest version of SDoc fixes a performance regression.
This version is at least twice as fast.
rails/sdoc#363
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance regression after rendering refactor
2 participants