-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Indexer-Grpc-V2] Add MetadataManager. #15727
Conversation
⏱️ 3h 42m total CI duration on this PR
🚨 2 jobs on the last run were significantly faster/slower than expected
|
f66cc55
to
bff3fa1
Compare
bff3fa1
to
501f87e
Compare
} | ||
|
||
// TODO(grao): This is a magic number, consider a different algorithm here. | ||
let capacity = std::cmp::max(candidates.iter().map(|c| c.1).max().unwrap() + 2, 20); |
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.
Using unwrap()
here could panic if all candidates have 0 active streams. Consider using unwrap_or(0)
to safely handle the empty or all-zero case:
let capacity = std::cmp::max(candidates.iter().map(|c| c.1).max().unwrap_or(0) + 2, 20);
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
|
||
tokio_scoped::scope(|s| { | ||
s.spawn(async move { | ||
self.metadata_manager.start().await.unwrap(); |
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.
Using unwrap()
on the async task could cause a panic if the metadata manager fails. Consider propagating the error instead with self.metadata_manager.start().await?
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
79c4698
to
43ecd36
Compare
8c77fc8
to
20819b0
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
} | ||
}); | ||
|
||
tokio::time::sleep(Duration::from_secs(1)).await; |
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.
Why do we need to ping so often? Can we sleep longer here?
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 actually want to make it more frequent since it's cheap. Under load a lot of things can happen in 1s.
.entry(address.clone()) | ||
.or_insert(LiveDataService::new(address)); | ||
entry.value_mut().recent_states.push_back(info); | ||
if entry.value().recent_states.len() > MAX_NUM_OF_STATES_TO_KEEP { |
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.
Why do we need to keep more than 1 state history?
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.
A sample use case is I can calculate the tps. (especially for debugging purpose, this can have much more information and granularity than grafana metric)
use tonic::transport::channel::Channel; | ||
use tracing::trace; | ||
|
||
const MAX_NUM_OF_STATES_TO_KEEP: usize = 100; |
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.
Adding some comments here would be helpful.
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.
Done
@@ -20,6 +20,9 @@ pub(crate) struct ServiceConfig { | |||
pub struct IndexerGrpcManagerConfig { | |||
pub(crate) chain_id: u64, | |||
pub(crate) service_config: ServiceConfig, | |||
pub(crate) self_advertised_address: String, |
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.
nit: either give it a type other than string or use socketaddr/url.
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.
Added a type.
for kv in &self.fullnodes { | ||
let (address, fullnode) = kv.pair(); | ||
let need_ping = fullnode.recent_states.back().map_or(true, |s| { | ||
Self::need_ping(s.timestamp.unwrap_or_default(), Duration::from_secs(1)) |
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.
thought: config these time/duration; we may need to experiment these number
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'm trying to avoid putting too many things into config, which confuse people. Let's keep it here now and only move it to config if we find it really necessary.
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.
approve to unblock; going to take another round of review
ac527bd
to
66619b8
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
66619b8
to
05e56a8
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
Description
How Has This Been Tested?
Key Areas to Review
Type of Change
Which Components or Systems Does This Change Impact?
Checklist