-
Notifications
You must be signed in to change notification settings - Fork 69
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
IF: Move vote processing off the net/main thread #2102
Comments
|
atomic<uint32_t> latest_block_num;
atomic<uint32_t> lib;
set_lib(lib) { lib = lib; notify_one(); }
add_vote( v ) { append(v); latest_block_num = std::max(latest_block_num, v.block_num); notify_one(); }
each thread:
while (true) {
_cond.wait([]() {
if (stopped || !empty) return true;
}
if (stopped) break;
remove_votes_before_lib();
uint32_t block_num = latest_block_num;
block_state_ptr bsp = forkdb.get(block_num);
for each connection by latency {
if( block_num != latest_block_num) {
block_num = latest_block_num;
bsp = forkdb.get(block_num);
}
process_votes_for_block(conn_id, bsp);
block_num = idx.get_latest_block_num();
}
}
process_votes_for_block(conn_id, bsp) {
for bsp->finalizer_size():
process_vote(conn_id, bsp);
} |
Are two threads enough? If each verify takes 2ms, this means that processing the 20 votes received would take a minimum of 20ms. Maybe that's OK, but I think 4 threads might be better. |
What's You would always process latest block's votes first? Where do you remove the vote after it is processed? |
The multi-index where one of the indexes is on block_num.
In process_vote. void process_vote(conn_id, bsp) {
auto itr = idx.find(conn_id, bsp->block_num())
if (itr != idx.end(); auto vote = *itr) {
vote_status s = bsp->aggregate_vote(vote);
idx.remove(itr);
--c->vote_count;
return s;
}
} |
|
Because it could change at any time, so check it periodically to see if we need to move to a different block. |
…orks now also can apply staged blocks in the fork db.
… to terminate at a block don't put any blocks above that in the fork database.
IF: Populated fork db ASAP; Vote processing off the main thread
In order to prepare for processing votes after a block arrives, move from processing votes immediately as they come in on the
net
thread andmain
thread. Also place blocks as soon as the block state is created into the fork database so they are available to be retrieved for vote processing.The text was updated successfully, but these errors were encountered: