Skip to content

Detect N+1 errors in development#1131

Merged
JPrevost merged 3 commits intomainfrom
bullet
Mar 8, 2023
Merged

Detect N+1 errors in development#1131
JPrevost merged 3 commits intomainfrom
bullet

Conversation

@JPrevost
Copy link
Member

@JPrevost JPrevost commented Mar 7, 2023

Why are these changes being introduced:

  • This app has a history of poor performance in production that we have been able to slowly adjust by investigating N+1 queries
  • The bullet gem gives us a more structured way of detecting, logging, and addressing these types of issues during development so we can avoid pushing new problems into production

Relevant ticket(s):

How does this address that need:

  • Adds Bullet gem and associated configuration
  • Using application in development and test envs, used the information provided to address N+1 queries and removed a few over eager loads.

Document any side effects to this change:

  • Running Bullet as part of our test suite would be ideal, but administrate is a bit complicated to fix the reported issues. We could probably ignore all of the administrate errors, but it was not yet clear if that was a good path so leaving it disabled in test is the current plan.
  • There are some over eager loads that track back to ActiveStorage. From my reading of the documentation, we are doing the calls properly so it wasn't clear yet how to proceed.

Developer

  • All new ENV is documented in README
  • All new ENV has been added to Heroku Pipeline, Staging and Prod
  • ANDI or Wave has been run in accordance to
    our guide and
    all issues introduced by these changes have been resolved or opened as new
    issues (link to those issues in the Pull Request details above)
  • Stakeholder approval has been confirmed (or is not needed)

Code Reviewer

  • The commit message is clear and follows our guidelines
    (not just this pull request message)
  • There are appropriate tests covering any new functionality
  • The documentation has been updated or is unnecessary
  • The changes have been verified
  • New dependencies are appropriate or there were no changes

Requires database migrations?

NO

Includes new or updated dependencies?

YES

Why are these changes being introduced:

* This app has a history of poor performance in production that we have
  been able to slowly adjust by investigating N+1 queries
* The bullet gem gives us a more structured way of detecting, logging,
  and addressing these types of issues during development so we can
  avoid pushing new problems into production

Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/ETD-569
* https://mitlibraries.atlassian.net/browse/ETD-570
* https://mitlibraries.atlassian.net/browse/ETD-609
* https://mitlibraries.atlassian.net/browse/ETD-608

How does this address that need:

* Adds Bullet gem and associated configuration
* Using application in development and test envs, used the information
  provided to address N+1 queries and removed a few over eager loads.

Document any side effects to this change:

* Running Bullet as part of our test suite would be ideal, but
administrate is a bit complicated to fix the reported issues. We could
probably ignore all of the administrate errors, but it was not yet
clear if that was a good path so leaving it disabled in test is the
current plan.
* There are some over eager loads that track back to ActiveStorage. From
my reading of the documentation, we are doing the calls properly so it
wasn't clear yet how to proceed.
@mitlib mitlib temporarily deployed to thesis-submit-pr-1131 March 7, 2023 18:39 Inactive
@coveralls
Copy link

coveralls commented Mar 7, 2023

Coverage Status

Coverage: 98.304% (+0.0008%) from 98.303% when pulling 1f2e74a on bullet into d33b44a on main.

@JPrevost JPrevost temporarily deployed to thesis-submit-pr-1131 March 7, 2023 18:48 Inactive
@JPrevost JPrevost temporarily deployed to thesis-submit-pr-1131 March 7, 2023 18:52 Inactive
@jazairi jazairi self-assigned this Mar 8, 2023
Copy link
Contributor

@jazairi jazairi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested this with prod data to see how it affects real-world performance, but the changes here make sense to me. I agree with the decision not to enable bullet in test for now. Glad you stumbled upon this gem -- seems like it'll be useful!

@JPrevost JPrevost merged commit d0a1017 into main Mar 8, 2023
@JPrevost JPrevost deleted the bullet branch March 8, 2023 18:13
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.

4 participants