-
Notifications
You must be signed in to change notification settings - Fork 10
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
Optimize block processing - Part 3 #802
Conversation
…s can be consolidated. If one already exists no reason to add another.
…imize-block-processing-part3
…imize-block-processing-part3
libraries/custom_appbase/include/eosio/chain/exec_pri_queue.hpp
Outdated
Show resolved
Hide resolved
libraries/custom_appbase/include/eosio/chain/exec_pri_queue.hpp
Outdated
Show resolved
Hide resolved
…lugin to disconnect
Note:start |
for (; i != end; p = i, ++i) { | ||
if ((*i)->priority() != priority) | ||
break; | ||
} |
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.
This seems wrong to me. Shouldn't we want to skip handlers which have the same priority, but a different id?
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.
The idea is the find the last posted function. If it same as you are attempting to post, don't bother.
if (i != end) { | ||
// ordered iterator appears to only be a forward iterator | ||
auto p = i; | ||
for (; i != end; p = i, ++i) { | ||
if ((*i)->priority() != priority) | ||
break; | ||
} | ||
if ((*p)->priority() == priority && (*p)->id() == id) | ||
return; | ||
} |
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.
Could it be as simple as this?
if (i != end) { | |
// ordered iterator appears to only be a forward iterator | |
auto p = i; | |
for (; i != end; p = i, ++i) { | |
if ((*i)->priority() != priority) | |
break; | |
} | |
if ((*p)->priority() == priority && (*p)->id() == id) | |
return; | |
} | |
if (i != end) { | |
// ordered iterator appears to only be a forward iterator | |
for (; i != end && (*i)->priority() == priority; ++i) | |
if ((*i)->id() == id) | |
return; | |
} |
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.
No. You have to find the last posted handler with the same priority and see if that one has the same id.
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 does it has to be the last posted one? Why does it matter if something else was posted later with the same priority?
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.
This goes with the more conservative approach of only de-dup on matching id for a given priority when it was the last id posted.
Say you have items in the queue, u=unique, pb=process_incoming_block
q9(u) q8(pb) q7(u)
Say you want to post a q6(pb)
, it is possible this is not safe to de-dup because if q7(u)
does something that needs q6(pb)
to run then you end up with q6(pb)
not running. So this goes with the more conservative route of only de-dup if q7(u)
is a pb
. Granted we could argue that q7(u)
should post a pb
if needs that to happen.
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.
The code I sent dedups only if it is the same id (pb) at the same priority, so in your example posting q6(pb)
would not dedup as there is no other q6(pb)
in the queue. Or am I missing something?
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.
The 9,8,7 are just order numbers. They are all the same priority.
q9(u) q8(pb) q7(u)
So your code would find q8(pb)
and return (de-dup). Want to only compare to q7(u)
and then non-dedup.
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.
Is there a reason for this requirement, i.e would the code not work if we didn't check that it was the last posted? It seems to me that either we want to dedup, and then we should just do it, or not.
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.
Been thinking about this. Maybe I am being too conservative. If the last item running needs to have a follow non-unique item it should post it.
…-part2' into GH-529-optimize-block-processing-part3
What was the rationale for not using |
|
annoying. Maybe it would be better to use |
…-unique id then do not post it
…imize-block-processing-part3
…imize-block-processing-part3
Part 3 of 3 of #529. See #688 for part 2 and #619 for part 1.
app().executor().post()
.on_incoming_block()
has been posted to the main thread, then another does not need to be added as theon_incoming_block
will execute any blocks ready from the fork database.Resolves #529