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

Reduce allocations in test/performance/bench_utilities.rb #2906

Merged
merged 11 commits into from
Jun 25, 2024

Conversation

japf
Copy link
Contributor

@japf japf commented Jun 16, 2024

Authors: Please fill out this form carefully and completely.

Reviewers: By approving this Pull Request you are approving the code change, as well as its deployment and mitigation plans.
Please read this description carefully. If you feel there is anything unclear or missing, please ask for updates.

What are you trying to accomplish?

This PR is reducing the allocations happening in the lib/primer/classify/utilities.rb file. During performance testing, we found that the Primer::Classify::Utilities.supported_selector? method was allocating more objects than expected. We have updated the method to use the Regexp object directly instead of creating a new Regexp object each time the method is called.

Screenshots

N/A

Integration

N/A

List the issues that this change affects.

N/A

Risk Assessment

  • Low risk the change is small, highly observable, and easily rolled back.
  • Medium risk changes that are isolated, reduced in scope or could impact few users. The change will not impact library availability.
  • High risk changes are those that could impact customers and SLOs, low or no test coverage, low observability, or slow to rollback.

What approach did you choose and why?

Anything you want to highlight for special attention from reviewers?

Accessibility

  • No new axe scan violation - This change does not introduce any new axe scan violations.

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Lookbook)
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

Copy link

changeset-bot bot commented Jun 16, 2024

⚠️ No Changeset found

Latest commit: e919482

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@camertron
Copy link
Contributor

Thanks for this @japf! I just merged main into your branch, which brings support for Ruby 3.3. You should be able to update the tests now.

@japf japf added the skip changeset Pull requests that don't change the library output label Jun 24, 2024
@japf
Copy link
Contributor Author

japf commented Jun 24, 2024

👋 @camertron,

I merged main again, edited the PR description and added the skip-changeset label. Please let me know if I'm missing anything.

@japf japf marked this pull request as ready for review June 24, 2024 11:56
@japf japf requested a review from a team as a code owner June 24, 2024 11:56
@japf japf requested a review from siddharthkp June 24, 2024 11:56
@camertron
Copy link
Contributor

Hey @japf, thanks for that! You'll also need to update the tests to reflect the new number of expected allocations.

@camertron
Copy link
Contributor

Ok, it looks like the class name for the new test was BenchClassify which is the same name as another one of our perf test classes (probably a copypasta oversight). I think that was causing our tests to assert against the wrong number of allocations, depending on the order in which the test files were loaded. Hopefully this latest run works 👍

@camertron
Copy link
Contributor

Huh, so weirdly if I run these new utility allocation tests multiple times, they report different numbers. We might need a warm-up or something before running them. Experimenting now.

@camertron camertron merged commit 953e878 into main Jun 25, 2024
36 of 37 checks passed
@camertron camertron deleted the japf/reduce-allocations-classify-utilities branch June 25, 2024 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip changeset Pull requests that don't change the library output
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants