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

[#11015] break down question result fetch by section #11567

Conversation

moziliar
Copy link
Contributor

@moziliar moziliar commented Feb 15, 2022

Fixes #11015

Refactor of #11017 due to branch diversion

Original problem

Feedback result page from session with too many responses will cause backend timeout or OOM. This is because of the sheer amount of data to be processed and kept in memory within one API call, and therefore suffers from scalability problem.

Outline of Solution

Frontend

When fetching feedback result with FULL_DETAIL intent, fetch by giver's and receiver's section separately. This is to ensure the scalability of result fetch action from the frontend and is guaranteed by the section size limit.

Section was created to limit the number of students per API call. Using it as the unit of result fetch will likely not run into OOM issue.
Currently, only expandQuestion will have such breakdown; expandSection will not be affected as it already fetches by section.

Backend

Adds ResultFetchType parameter which fetches feedback responses by giverSection, receiverSection, or both. This is only applied in FULL_DETAIL intent, and will be expanded to forUser result fetch should there be concerns arising from that data path.

Testing

FeedbackResultsPageE2E test should cover the frontend correctness of this solution.

Unit tests are created to ensure the parameters are working as intended.

@moziliar moziliar added the s.Ongoing The PR is being worked on by the author(s) label Feb 15, 2022
@moziliar moziliar force-pushed the 11015-break-down-question-result-fetch-by-section branch from da8a0f0 to 62f7ad8 Compare February 15, 2022 06:30
@moziliar moziliar marked this pull request as ready for review February 16, 2022 10:21
@jianhandev jianhandev added s.ToReview The PR is waiting for review(s) and removed s.Ongoing The PR is being worked on by the author(s) labels Feb 16, 2022
Copy link
Contributor

@jianhandev jianhandev left a comment

Choose a reason for hiding this comment

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

LGTM

@madanalogy madanalogy added s.FinalReview The PR is ready for final review and removed s.ToReview The PR is waiting for review(s) labels Feb 17, 2022
Copy link
Member

@wkurniawan07 wkurniawan07 left a comment

Choose a reason for hiding this comment

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

Need more tests. There are no tests for fetch type that is not BOTH right now.

@moziliar
Copy link
Contributor Author

@wkurniawan07 src/test/java/teammates/ui/webapi/GetSessionResultsActionTest.java
Added test here; merging of the results (in SessionResultData) from both GIVER and RECEIVER types is hard at the backend as it will involve complicated wiring of deserializing the data. The test should be covered by e2e where the same result fetch is still tested.

@wkurniawan07
Copy link
Member

src/test/java/teammates/ui/webapi/GetSessionResultsActionTest.java
Added test here

This is merely testing that the API returns the value as returned by logic.getSessionResultsForCourse. Which tests guarantee that logic.getSessionResultsForCourse and the DB layer method return the right value, given the fetch type?

The test should be covered by e2e where the same result fetch is still tested.

E2E tests cannot replace lower level tests.

@moziliar moziliar force-pushed the 11015-break-down-question-result-fetch-by-section branch from 7686905 to 52521b8 Compare February 18, 2022 02:15
@madanalogy madanalogy added s.Ongoing The PR is being worked on by the author(s) and removed s.FinalReview The PR is ready for final review labels Feb 18, 2022
@wkurniawan07 wkurniawan07 added this to the V8.11.0 milestone Mar 14, 2022
@nusoss-bot
Copy link

Guys, This PR seems to be stalling (no activities for the past 7 days). 🐌 😢
Hope someone can get it to move forward again soon...

@wkurniawan07 wkurniawan07 modified the milestones: V8.11.0, V8.12.0 Mar 29, 2022
@madanalogy madanalogy modified the milestones: V8.12.0, V8.13.0 Apr 3, 2022
@wkurniawan07 wkurniawan07 modified the milestones: V8.13.0, V8.14.0 Apr 3, 2022
@nusoss-bot
Copy link

Guys, This PR seems to be stalling (no activities for the past 7 days). 🐌 😢
Hope someone can get it to move forward again soon...

Copy link
Member

@wkurniawan07 wkurniawan07 left a comment

Choose a reason for hiding this comment

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

Apologies for the delayed review. Just one change requested.

Also, please ensure that the section results are fetched sequentially in order to prevent burst of requests in courses with large number of sections. (I did see the concatMap, so just need to double confirm)

intent: Intent.FULL_DETAIL,
groupBySection: sectionName,
sectionByGiverReceiver: 'receiver',
}),
Copy link
Member

Choose a reason for hiding this comment

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

There shouldn't be a need to split by giver/receiver here. There is a high likelihood for large amount of duplicates. Splitting by section is enough to give the needed performance boost.

It does mean that the back-end split of giver/receiver is not actually needed right now, but they can and will have their uses in other view types (GRQ and alike) eventually, so no work is wasted here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to 'both'. Works as expected.

@moziliar
Copy link
Contributor Author

moziliar commented Apr 15, 2022

image

Currently, the result fetch is in a sequential manner. Probably need to set up jest tests to verify too.

Copy link
Member

@wkurniawan07 wkurniawan07 left a comment

Choose a reason for hiding this comment

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

No outstanding change requests. I will give the official approval once the lint violation is fixed. (very minor)

@moziliar moziliar force-pushed the 11015-break-down-question-result-fetch-by-section branch from 76f41c1 to 6b142f2 Compare April 15, 2022 15:37
@wkurniawan07 wkurniawan07 added s.ToMerge The PR is approved by all reviewers including final reviewer; ready for merging c.Task Other non-user-facing works, e.g. refactoring, adding tests and removed s.FinalReview The PR is ready for final review labels Apr 15, 2022
@wkurniawan07 wkurniawan07 merged commit bcc5671 into TEAMMATES:master Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c.Task Other non-user-facing works, e.g. refactoring, adding tests s.ToMerge The PR is approved by all reviewers including final reviewer; ready for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optimize frontend result page fetching
5 participants