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

DB speedup in API:: controller/request specs #25516

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

mjankowski
Copy link
Contributor

Reduce the number of app requests being made in specs where there are multiple assertions against the same request response.

When running bin/rspec spec/controllers/api spec/requests/api:

Before changes…

  • ~40,100 total sql.active_record events
  • ~2,650 total factory.create events
  • Runs of ~33 seconds

After changes…

  • ~28,650 total sql.active_record events
  • ~1,900 total factory.create events
  • Runs of ~24 seconds

Total changes…

  • ~11,500 fewer db transactions, including ~700 fewer factories
  • ~10s faster run time

This is basically doing the same thing I did in #25486 - but for the entirety of the request and controller api specs. I think there's room to do more of this in the rest of the (non API) controller/request specs as well, but this is already a large diff and I didn't want it to get larger.

The vast majority of these are combining what was an http status check from a response into the example right under it which asserted something more meaningful. There were a few areas which could be further improved by chaining change blocks together, but I held off on that here.

@renchap renchap added testing Automated lint and test suites ruby Pull requests that update Ruby code labels Jun 20, 2023
@github-actions
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions
Copy link
Contributor

This pull request has resolved merge conflicts and is ready for review.

@github-actions
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions
Copy link
Contributor

This pull request has resolved merge conflicts and is ready for review.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 8, 2023

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 8, 2023

This pull request has resolved merge conflicts and is ready for review.

@github-actions
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions
Copy link
Contributor

This pull request has resolved merge conflicts and is ready for review.

@github-actions
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

Reduce the number of app requests being made in specs where there are
multiple assertions against the same request response.

When running `bin/rspec spec/controllers/api spec/requests/api`:

Before changes…

- ~40,100 total `sql.active_record` events
- ~2,650 total `factory.create` events
- Runs of ~33 seconds

After changes…

- ~28,650 total `sql.active_record` events
- ~1,900 total `factory.create` events
- Runs of ~24 seconds

Total changes…

- ~11,500 fewer db transactions, including ~700 fewer factories
- ~10s faster run time
@github-actions
Copy link
Contributor

This pull request has resolved merge conflicts and is ready for review.

@ClearlyClaire ClearlyClaire merged commit fd9dea2 into mastodon:main Oct 13, 2023
27 checks passed
@mjankowski mjankowski deleted the spec-db-api-controllers branch October 13, 2023 13:28
ClearlyClaire added a commit that referenced this pull request Oct 13, 2023
Follow-up to #25475 which did not remove the replaced controller spec, and
apply the changes made in #25516
ClearlyClaire added a commit that referenced this pull request Oct 13, 2023
Follow-up to #25475 which did not remove the replaced controller spec, and
apply the changes made in #25516
danielmbrasil added a commit to danielmbrasil/mastodon that referenced this pull request Oct 13, 2023
danielmbrasil added a commit to danielmbrasil/mastodon that referenced this pull request Oct 16, 2023
audiodude pushed a commit to audiodude/mastodon that referenced this pull request Oct 23, 2023
000hen pushed a commit to thenapnetwork/nap-mastodon that referenced this pull request Dec 6, 2023
vmstan pushed a commit to vmstan/mastodon that referenced this pull request Dec 14, 2023
vmstan pushed a commit to vmstan/mastodon that referenced this pull request Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ruby Pull requests that update Ruby code testing Automated lint and test suites
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants