dojo icon indicating copy to clipboard operation
dojo copied to clipboard

feat(katana): dedup fork request

Open cwkang1998 opened this issue 1 year ago • 4 comments
trafficstars

Description

Implements a request deduplication process via the use of a HashSet on the requests. This also requires adding a key for the pending_requests vector so we can add any pending requests that was popped back to the queue.

The key for the requests deduplication was originally implemented as a String, but changed to Enum after to enforce the possible types.

Considered IndexMap to reduce need to add an extra data structure, but since that requires adding a package and this should achieve the same result, kept this implementation.

Related issue

Closes #1465.

Tests

  • [x] Yes
  • [ ] No, because they aren't needed
  • [ ] No, because I need help

The tests for the changes I've made passed. However some seemingly unrelated tests are failing and I am not sure what's the exact issue. Hopefully its a setup issue and its only failing on my machine.

Added to documentation?

  • [ ] README.md
  • [ ] Dojo Book
  • [ ] No documentation needed

Not sure docs is needed for this on the dojo book, but if needed I can add to it. For now only comments are added for explanation.

Checklist

  • [x] I've formatted my code (scripts/prettier.sh, scripts/rust_fmt.sh, scripts/cairo_fmt.sh)
  • [x] I've linted my code (scripts/clippy.sh, scripts/docs.sh)
  • [x] I've commented my code
  • [ ] I've requested a review after addressing the comments

cwkang1998 avatar May 25 '24 21:05 cwkang1998

Codecov Report

Attention: Patch coverage is 96.35535% with 16 lines in your changes missing coverage. Please review.

Project coverage is 55.91%. Comparing base (4671d9c) to head (ec163c5). Report is 105 commits behind head on main.

Files with missing lines Patch % Lines
...ana/storage/provider/src/providers/fork/backend.rs 96.35% 16 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2001      +/-   ##
==========================================
- Coverage   57.41%   55.91%   -1.50%     
==========================================
  Files         406      439      +33     
  Lines       51330    56147    +4817     
==========================================
+ Hits        29470    31395    +1925     
- Misses      21860    24752    +2892     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar May 25 '24 22:05 codecov[bot]

@cwkang1998 sorry for the delay on this one. A lot's of changes have happen since. @kariy any recommendation around this issue and how it should be tackled?

glihm avatar Jul 09 '24 16:07 glihm

Hey, sorry for being so slow on this as well! I think I am still missing some implementation details for this so I will get an update to this PR within this week, but if there's any changes I will have to make please do tell me and I will try my best to implement it asap.

cwkang1998 avatar Jul 09 '24 18:07 cwkang1998

Hey, sorry for being so slow on this as well! I think I am still missing some implementation details for this so I will get an update to this PR within this week, but if there's any changes I will have to make please do tell me and I will try my best to implement it asap.

nope, nothing changed from what we discussed before.

this PR is merely for optimization purpose, and is very isolated from changes made on other part of the codebase and isn't tight to the system's architecture itself.

so the current changes made are already good, we're only missing the part where we wait for the response of the initial request and reuse it for the deduped ones.

kariy avatar Jul 10 '24 14:07 kariy

@cwkang1998 no pressure but do you think you can continue this PR? otherwise i can take over it as necessary.

kariy avatar Nov 19 '24 12:11 kariy

@cwkang1998 no pressure but do you think you can continue this PR? otherwise i can take over it as necessary.

Just added the changes required to make the result return as expected. Sorry for such a long delay.

Will attempt to add more tests to this.

cwkang1998 avatar Dec 01 '24 00:12 cwkang1998

Walkthrough

Ohayo, sensei! The pull request introduces significant enhancements to the backend.rs file within the Katana project. Key modifications include the creation of a BackendResponse enum for unified response handling, updated error management using Arc, and the implementation of a deduplication mechanism for incoming requests. The request handling logic has been refactored to prevent duplicate processing of identical requests, ensuring efficient use of resources. Method signatures have been updated to reflect these changes, and tests have been expanded to verify the new deduplication functionality.

Changes

File Path Change Summary
crates/katana/storage/provider/src/providers/fork/backend.rs - Added BackendResponse enum.
- Updated BackendError to include UnexpectedReceiveResult(Arc<anyhow::Error>).
- Refactored request methods to return BackendResponse.
- Implemented request deduplication logic.
- Updated type alias for BackendRequestFuture.

Assessment against linked issues

Objective Addressed Explanation
Implement request deduplication ( #1465 )

Possibly related PRs

  • #2545: Modifications to backend.rs that align with request handling logic enhancements made in this PR.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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 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.

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.

coderabbitai[bot] avatar Dec 01 '24 00:12 coderabbitai[bot]

Please run cargo +nightly-2024-08-28 fmt --all and ./scripts/clippy.sh

kariy avatar Dec 15 '24 19:12 kariy