dojo
dojo copied to clipboard
feat(katana): dedup fork request
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
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.
@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?
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.
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.
@cwkang1998 no pressure but do you think you can continue this PR? otherwise i can take over it as necessary.
@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.
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.rsthat 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?
🪧 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
@coderabbitaiin 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
@coderabbitaiin 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 pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere 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.
Please run cargo +nightly-2024-08-28 fmt --all and ./scripts/clippy.sh