-
Notifications
You must be signed in to change notification settings - Fork 257
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
fix: duplicate read proto #1737
Conversation
WalkthroughThe recent updates in the codebase include optimizations in memory management by using references in the Changes
Assessment against linked issues
Possibly related issues
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1737 +/- ##
==========================================
+ Coverage 86.93% 87.14% +0.21%
==========================================
Files 155 153 -2
Lines 15540 15610 +70
==========================================
+ Hits 13509 13604 +95
+ Misses 2031 2006 -25 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can u update the description of the PR with the changes that fixed the issue, thanks!
Ok, it's done. |
The issue is addressed:
|
path: &str, | ||
file_dp: FileDescriptorProto, | ||
) -> anyhow::Result<ProtoMetadata> { | ||
if file_dp.package.is_none() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to build caching inside of ResourceReader
, something like:
ResourceReader::init(runtime, true)
ResourceReader, could maintain a HashMap of file path and content and cache it locally when enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If follow this, we need change &self
of ResouceReader::read_file
to &mut self
, and all other structures contain it. To fix a small issue, it modifies too much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And HashMap
is not Send, to do it, maybe we need lock it, and it will become bottleneck.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can wrap it in a Arc of Mutex. This isn't hot code so performance shouldn't be a problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And there is another issue, the first reading is called by ConfigReader::resource_reader
, the second is called by ConfigReader::proto_reader
, they are different object. Maybe we need to put HashMap
in ConfigReader`.
Reopen in #1741 |
Summary:
This PR fixes related issue by avoiding double read file, the second read proto file will use the content of the first directly.
Current output:
Issue Reference(s):
Fixes #... (Replace "..." with the issue number)
Close #1734
/claim #1734
Build & Testing:
cargo test
successfully../lint.sh --mode=fix
to fix all linting issues raised by./lint.sh --mode=check
.Checklist:
<type>(<optional scope>): <title>
Summary by CodeRabbit