Skip to content

Conversation

@jhs-panda
Copy link
Contributor

Description

cached entries in manage submissions to reduce load times

Motivation and Context

manage submissions loading time slow, hopefully reduced with caching

How Has This Been Tested?

Tested with creating new submissions (on manage submissions page), editing submissions, deleting submissions, and making new submissions. Also ensured current features on manage submissions page still work. Might've missed some functions, would greatly appreciate if checked to make sure caching does not break functionality.
Since it edits handin.rb, make sure to run rails server to make sure changes integrate.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have run rubocop and erblint for style check. If you haven't, run overcommit --install && overcommit --sign to use pre-commit hook for linting
  • My change requires a change to the documentation, which is located at Autolab Docs
  • I have updated the documentation accordingly, included in this PR

@jhs-panda jhs-panda requested review from a team and dwang3851 and removed request for a team March 8, 2025 05:02
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 8, 2025

📝 Walkthrough

"""

Walkthrough

The changes update two controllers to handle caching for submission data. In the assessment controller’s handin method, cache entries for submission IDs and the corresponding mapping are cleared when a new submission is processed. In the submissions controller, the index method now retrieves submission IDs and the mapping from a cache (stored for one day) instead of querying the database directly, while the new method additionally clears these caches upon creating a new submission.

Changes

File(s) Change Summary
app/controllers/assessment/handin.rb Added code to clear cache entries ["submission_ids", @assessment.id] and ["submissions_to_cud", @assessment.id] during submission processing.
app/controllers/submissions_controller.rb Modified the index method to cache submission IDs and associated mapping (submissions_to_cud) for one day. Updated the new method to clear these cache entries upon submission.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Controller
    participant Cache
    participant DB

    User->>Controller: Create new submission
    Controller->>Cache: Clear cache entries ["submission_ids", assessment.id] and ["submissions_to_cud", assessment.id]
    Controller->>DB: Process submission

    User->>Controller: Request submissions list
    Controller->>Cache: Check for submission_ids cache
    alt Cache Hit
        Cache-->>Controller: Return cached submission IDs
        Controller->>DB: Query submissions using cached IDs
    else Cache Miss
        Controller->>DB: Query submissions directly
        DB-->>Controller: Return submission data
        Controller->>Cache: Cache submission IDs (1 day)
        Controller->>Cache: Cache submissions_to_cud mapping (1 day)
    end
Loading

Suggested reviewers

  • dwang3851
    """

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7786338 and 3f4148e.

📒 Files selected for processing (1)
  • app/controllers/submissions_controller.rb (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/controllers/submissions_controller.rb
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9e96814 and 7786338.

📒 Files selected for processing (2)
  • app/controllers/assessment/handin.rb (1 hunks)
  • app/controllers/submissions_controller.rb (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test
🔇 Additional comments (3)
app/controllers/assessment/handin.rb (1)

30-33: Good implementation of cache clearance when submissions are made.

The cache clearing is necessary when a new submission is made to ensure the submissions list in the manage submissions page stays up-to-date. This implementation properly invalidates the cache at the right moment in the submission process.

app/controllers/submissions_controller.rb (2)

20-25: Efficient caching implementation for submission IDs.

Caching submission IDs instead of entire objects is a good pattern for performance optimization. This reduces memory usage while still enabling quick data retrieval when needed.


27-35: Well-structured cache for submissions mapping.

Good use of JSON serialization for the mapping data with appropriate expiration time. This will significantly reduce database load on the submissions page.

Copy link
Contributor

@dwang3851 dwang3851 left a comment

Choose a reason for hiding this comment

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

Overall functionality seems to work the same, but does the caching work? I'm not sure if I ran something wrong, but the speed of loading the manage submissions page does not seem like it always goes down. At most on my machine, it goes down by ~10%, but sometimes it also increases after things are cached.

Copy link
Contributor

@dwang3851 dwang3851 left a comment

Choose a reason for hiding this comment

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

After further discussion offline, this PR caches some parts of the manage submissions page, but a future pr will have to deal with caching the views, which is the main factor influencing loading times

@jhs-panda jhs-panda enabled auto-merge March 17, 2025 20:17
@jhs-panda jhs-panda added this pull request to the merge queue Apr 22, 2025
Merged via the queue into master with commit 9cc857f Apr 22, 2025
6 checks passed
@jhs-panda jhs-panda deleted the joy-speed-investigation branch April 22, 2025 00:10
NicholasMy pushed a commit to UB-CSE-IT/Autolab that referenced this pull request Jun 3, 2025
* Caching some data from index, todo fix caching issues for submission data

* Cached submission_ids instead of trying to do full data entries.

* Changed expiration time of cache entries and allow for cache remake after new submission.

* Uncommented necessary lines removed when testing.

* Finished adding functionality of caching manage submissions.

* Cleaned up code.

(cherry picked from commit 9cc857f)
@coderabbitai coderabbitai bot mentioned this pull request Oct 30, 2025
6 tasks
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.

3 participants