-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Collect and log more timing information (issue #500) #523
Collect and log more timing information (issue #500) #523
Conversation
- Introduce `longform` flag for `list` subcommand, with following output format: For each output, we 1. Print outpoint and oldest sat contained 2. Followed by each ordinal range, indented by two spaces, and the size of the range
- time elapsed for database commit - time elapsed for updating (=indexing to) database/btree in between commits
- Allow multiple outpoints for list subcommand
Collect and log more timing information:
Since the logging and time calculation is somewhat complex, how about refactoring it into a method that we call twice, instead of duplicating:
|
I had tried that but struggled with passing the WriteTransaction around. Will try once more. |
I extracted a method as suggested. Not sure the way I handle the potential errors from commit() is OK like this. Realize that extracting methods gets tricky with the error handling approach.
|
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 some comments! I think you can use ?
for error handling.
@@ -136,7 +137,7 @@ impl Index { | |||
let done = self.index_block(&mut wtx)?; | |||
|
|||
if block % 1000 == 0 { | |||
wtx.commit()?; | |||
last_commit_time = Self::commit_and_log(wtx, last_commit_time, self.height()?.n()).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.
Can you use ?
for error handling? Also thinking that last_commit_time
can be taking by &mut
so it can just be updated in-place:
last_commit_time = Self::commit_and_log(wtx, last_commit_time, self.height()?.n()).unwrap(); | |
Self::commit_and_log(wtx, &mut last_commit_time, self.height()?.n())?; |
@@ -136,7 +137,7 @@ impl Index { | |||
let done = self.index_block(&mut wtx)?; | |||
|
|||
if block % 1000 == 0 { | |||
wtx.commit()?; | |||
last_commit_time = Self::commit_and_log(wtx, last_commit_time, self.height()?.n()).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.
Can you use ?
for error handling? Also thinking that last_commit_time
can be taking by &mut
so it can just be updated in-place:
last_commit_time = Self::commit_and_log(wtx, last_commit_time, self.height()?.n()).unwrap(); | |
Self::commit_and_log(wtx, &mut last_commit_time, self.height()?.n())?; |
@@ -147,11 +148,28 @@ impl Index { | |||
block += 1; | |||
} | |||
|
|||
wtx.commit()?; | |||
Self::commit_and_log(wtx, last_commit_time, self.height()?.n()).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.
Self::commit_and_log(wtx, last_commit_time, self.height()?.n()).unwrap(); | |
Self::commit_and_log(wtx, &mut last_commit_time, self.height()?.n())?; |
|
||
Ok(()) | ||
} | ||
|
||
fn commit_and_log( | ||
wtx: WriteTransaction, | ||
last_commit_time: Instant, |
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.
last_commit_time: Instant, | |
last_commit_time: &mut Instant, |
height, | ||
(now - commit_start_time).as_millis() | ||
); | ||
Ok(Instant::now()) |
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.
Ok(Instant::now()) | |
*last_commit_time = Instant::now(); | |
Ok(()) |
wtx: WriteTransaction, | ||
last_commit_time: Instant, | ||
height: u64, | ||
) -> Result<Instant> { |
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.
) -> Result<Instant> { | |
) -> Result { |
@@ -2,22 +2,36 @@ use super::*; | |||
|
|||
#[derive(Debug, Parser)] | |||
pub(crate) struct List { | |||
outpoint: OutPoint, | |||
#[clap(long, short, help = "Use extended output format")] |
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 the extended output format code snuck in 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.
Ups, yes. I must have messed something up after I had merged those changes into my master.
Collect more timing info as per #500
Collect and log: