-
Notifications
You must be signed in to change notification settings - Fork 71
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
[4.0] Fix block time reporting log statement #1434
Conversation
…producer to Block time report.
In this location, I think we do I think it would be more logical, everytime we effectively do the equivalent of:
We should immediately afterwards do: This way we can ensure we don't count the same interval twice as idle. And these two statements should be in a |
Also Maybe |
I think a better design would be for the time tracker to hold the class block_time_tracker
{
enum class time_usage { idle, success, fail, last };
void add_time(time_usage u)
{
auto now = fc::time_point::now();
_time[static_cast<int>(u)] += now - _unaccounted_tstamp;
_unaccounted_tstamp = now;
}
std::array<fc::microseconds, static_cast<int>(time_usage::last)> _time;
}; |
No, the only exception here (outside alloc exceptions which we can ignore since those are program exit) is via the |
The idle time does not start from there. It starts at the end of processing. Adding it here just makes it less likely you notice the logic is wrong. |
Interesting. I guess I have always thought of the term |
A bit of Deja Vu on this. Seems like we had a similar discussion already. I'll see if I can clean up the current impl some. |
I'm not following. Either we can't have exceptions (in which case we can remove the try/catch block and the exception handler), or we can have exceptions (and when we do we will call |
Yes, but when we call |
haha I already forgot all about it! You have a better memory than I do (not a high bar :-). |
The main reason the try-catch is here is for the |
So if that happens, we'll call |
Yes, it is used in unix, but I was more thinking of the generic definition. But I'm fine with timepoint as well. However, because we do update this timepoint, it is not necessarily the point we became idle, but really the point at which we last accounted for idle time (and updated the variable). That's what I was trying to convey with |
I think I finally see what you are saying. Thanks! No idea why that |
@greg7mdp Refactored to use RAII for a simpler interface. |
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.
Nice changes.
I'd prefer with my suggestions below, so that everytime we add a time interval to success/fail/idle time, we also reset the last_trx_time_point
break; // just reset timer which happens below | ||
} | ||
_block_time_tracker.start_idle_time(); |
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.
break; // just reset timer which happens below | |
} | |
_block_time_tracker.start_idle_time(); | |
_block_time_tracker.start_idle_time(); // just reset timer | |
break; | |
} |
if (!pr.failed) { | ||
trx_tracker.trx_success(); | ||
} |
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.
Should we count exhausted transactions as successful?
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.
They didn't fail, so don't want to count them as failed. We could count as other
, but other
is suppose to be time not spent evaluating trxs. We could add a whole new category, but that seems like it would just muddy the water. I think success is the best option. Time we spent successfully executing transactions; which is true.
@@ -2661,6 +2702,8 @@ void producer_plugin_impl::schedule_production_loop() { | |||
} else { | |||
fc_dlog(_log, "Speculative Block Created"); | |||
} | |||
|
|||
_time_tracker.start_idle_time(); |
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.
Hum, I wonder if it shouldn't be add_idle_time
, with the change I mentioned before in add_idle_time
resetting last_trx_time_point = 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.
I don't understand; there is no idle time to add.
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, I see that start_idle_time();
does:
last_trx_time_point = now;
So assuming that now
!= last_trx_time_point
, what was the time spent between last_trx_time_point
and now
used for?
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.
It was used for start block which includes potentially many trx processing.
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.
Actually, we should probably call start_idle_time()
only in ~trx_time_tracker() {
(where we skip time to be accounted as other
), and only call add_idle_time()
elsewhere.
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 create a trx_time_tracker
only when we start processing a transaction, right? So could it do add_other_time
in its constructor?
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.
BTW I really like the RAII implementation!
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 create a
trx_time_tracker
only when we start processing a transaction, right? So could it doadd_other_time
in its constructor?
But then you are just back to what it does now except you explicitly track the value instead of just calculate it.
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.
Hum, it is kind of true, especially with the current version of the code which increases the time_point every time we add a duration.
But still, if we track the "other" value explicitly, we can verify that the sum of all accounted times is the elapsed time, which may be not true if we were to create trx_time_tracker
objects on more than one thread for example.
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 explicit tracking of other. Also added a pause/unpause for when in read-window as it didn't seem correct to call that "other" time.
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.
Nice! I think the code is easier to follow 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.
Not for this PR. We report timing only in debug
logging, but we track timing no matter whether logging is enabled or not. Not sure how much time is spent on tracking in non-debugging mode.
I wonder if this shouldn't be |
Fix issue with the tracking of block idle time.
Add producer name to the block time log statement.
Note: time logging trxs is now included in the success/fail time.
Resolves #1360
Resolves #1417