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

feat: improve performance of matrix when multiple selectors are specified #631

Merged
merged 8 commits into from Aug 21, 2023

Conversation

bethesque
Copy link
Member

@bethesque bethesque commented Aug 19, 2023

This PR is practically un-reviewable, as I have re-written and refactored large chunks of the matrix code, for both performance and readability reasons. It had to be done however, and I'm pleased with the results.

Things worth noting:

Performance optimisation

  • To reproduce the performance issues we have in prod on my local machine, I had to use a postgres docker container with --cpu-period=100000 --cpu-quota=50000, because my dev machine has way more CPU than our prod database, and the queries would otherwise run practically instantaneously.
  • For the very large tenant dataset that was causing us problems recently
    • calculating the integrations has been reduced from 26 seconds to a few hundred milliseconds
    • performing the actual matrix query has been reduced from 26 seconds to 4 seconds
    • the overall time has been reduced from almost a minute to 5 seconds
    • there may be further possibility for optimisation, but it will be diminishing returns

Refactoring

  • The very large PactBroker::Matrix::Repository class has had its logic split up into a bunch of smaller, single purpose classes that are hopefully much more understandable.
  • Despite the large number of production code changes, there was only one change required in in the test code, and the matrix query code is the most thoroughly tested piece of code in the project, so I'm as confident as I can be that I have not introduced any bugs.

@bethesque
Copy link
Member Author

MySQL tests are failing, but I'll fix them up later - we don't use MySQL in pf.

@Inksprout
Copy link
Contributor

Love the added method descriptions❤️

@bethesque
Copy link
Member Author

Beth in ten years doing the next refactor will thank Beth now for those comments.

@bethesque bethesque merged commit 58a2860 into master Aug 21, 2023
17 of 19 checks passed
@bethesque bethesque deleted the feat/matrix-refactor branch August 21, 2023 03:24
bethesque added a commit that referenced this pull request Mar 22, 2024
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.

None yet

2 participants