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

perf: use batch loading for BasicUserDetails #932

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

ACLay
Copy link
Contributor

@ACLay ACLay commented Feb 3, 2025

Description

Expands the user batch loading from #469 to apply to BasicUserDetails as well, since the basic variant is quite widely used, and thus causes a lot of calls to the slow external user service at STFC. By combining multiple external calls into one we'll have to pay the time penalty of making network calls fewer times, and when that's ~100ms for each call in our prod environment, it'll add up to quite a bit of user-data-heavy requests.

Motivation and Context

How Has This Been Tested

I made 3 local page loads of access panel 11's assignments, recording the time taken by the main 3 calls when starting with an empty users cache. Due to react's dev setup making calls twice, this results in 6 calls for each. For those runs I also tracked the number of UOWS calls made. All times are in milliseconds

Method Call time (current client) Call time (with batching) Average time saved Percentage improvement
getFap 87 89 83 83 104 125 66 68 54 55 73 77 29.666 31%
getFapMembers 716 735 704 721 674 675 446 564 589 577 622 642 130.833 18%
getFapProposals 711 741 702 725 645 674 538 562 593 581 612 644 111.333 16 %
Attempt UOWS calls - no batching UOWS calls - batching
1 71 38
2 86 48
3 72 49

Fixes

Closes UserOfficeProject/issue-tracker#1197

Changes

Depends on

UserOfficeProject/mock-uows#19

While the test suite as a whole is passing here, some tests in isolation would have failed without this update to the mock uows, which has already merged. The initial passing state was I believe due to requests for individual users being made first in other tests and then cached in the backend. Without that, any test that first requests multiple users with batch loading would have failed as the mock server would only give one user's details.

Tests included/Docs Updated?

  • I have added tests to cover my changes.
  • All relevant doc has been updated

@ACLay ACLay marked this pull request as ready for review February 6, 2025 11:45
@ACLay ACLay requested a review from a team as a code owner February 6, 2025 11:45
@ACLay ACLay requested review from mehta-pooja123 and removed request for a team February 6, 2025 11:45
"localRoot": "${workspaceFolder}",
"remoteRoot": "C:\\app"
"localRoot": "${workspaceFolder}/apps/backend",
"remoteRoot": "/app"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This gets rid of our old windows container debug profile and replaces it with the newer one that our debug instructions on confluence advise putting here. Once this merges in, that section will need to be updated https://user-office-project.atlassian.net/wiki/spaces/UOP/pages/19136712/STFC+development+workflow#Debugging-the-backend

@ACLay ACLay requested review from a team and bolmsten and removed request for a team February 10, 2025 14:08
Copy link
Contributor

@TCMeldrum TCMeldrum left a comment

Choose a reason for hiding this comment

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

Looks good to me. Out of interest if the number of calls to the UOWS is cut down by a half does that mean only 2 people are being batch loaded at a time?

@ACLay
Copy link
Contributor Author

ACLay commented Feb 12, 2025

Seems like it. I guess the batching might be done at a more local level within each query, like if we're loading proposals on the panel one by one, it's probably not the fastest to batch up and only request the reviewers at the very end. Plus there's likely going to be a lot of repeats in the reviewers requested in the panel, so a lot of requests are already be dealt with and reduced in the initial unbatched case by the caching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optimise STFC user loading and cacheing
3 participants