-
Notifications
You must be signed in to change notification settings - Fork 72
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
Remove thread hop to producer thread for trx signature recovery #1859
Conversation
[this, trx{trx}, &chain, time_limit{max_trx_cpu_usage}, trx_type, | ||
api_trx, is_transient, next{std::move(next)}, return_failure_traces]() mutable { | ||
|
||
transaction_metadata_ptr trx_meta; | ||
try { | ||
trx_meta = transaction_metadata::recover_keys( trx, chain.get_chain_id(), time_limit, trx_type, chain.configured_subjective_signature_length_limit() ); | ||
} catch(...) { | ||
// use read_write when read is likely fine; this maintains previous behavior of next() always being called from the main thread | ||
app().executor().post(priority::low, exec_queue::read_write, | ||
[ex_ptr = std::current_exception(), this, trx{std::move(trx)}, is_transient, next{std::move(next)}]() { | ||
auto start = fc::time_point::now(); | ||
auto idle_time = this->_time_tracker.add_idle_time(start); | ||
auto trx_tracker = this->_time_tracker.start_trx(is_transient, start); | ||
fc_tlog(_log, "Time since last trx: ${t}us", ("t", idle_time)); | ||
auto ex_handler = | ||
[this, is_transient, &next, &trx](fc::exception_ptr ex) { | ||
this->log_trx_results(trx, nullptr, ex, 0, is_transient); | ||
next(std::move(ex)); | ||
}; | ||
try { | ||
std::rethrow_exception(ex_ptr); | ||
} CATCH_AND_CALL(ex_handler) | ||
}); | ||
return; | ||
} | ||
|
||
app().executor().post(priority::low, exec_queue::read_write, | ||
[this, trx_meta{std::move(trx_meta)}, api_trx, is_transient, next{std::move(next)}, return_failure_traces]() mutable { | ||
auto start = fc::time_point::now(); | ||
auto idle_time = this->_time_tracker.add_idle_time(start); | ||
auto trx_tracker = this->_time_tracker.start_trx(is_transient, start); | ||
fc_tlog(_log, "Time since last trx: ${t}us", ("t", idle_time)); | ||
|
||
auto exception_handler = | ||
[this, is_transient, &next, &trx_meta](fc::exception_ptr ex) { | ||
this->log_trx_results(trx_meta->packed_trx(), nullptr, ex, 0, is_transient); | ||
next(std::move(ex)); | ||
}; | ||
try { | ||
if (!this->process_incoming_transaction_async(trx_meta, api_trx, return_failure_traces, trx_tracker, next)) { | ||
if (this->in_producing_mode()) { | ||
this->schedule_maybe_produce_block(true); | ||
} else { | ||
this->restart_speculative_block(); | ||
} | ||
} | ||
} | ||
CATCH_AND_CALL(exception_handler); | ||
}); | ||
} ); |
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 it would be better to remove all occurences of this->
in this code.
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.
Removed
}); | ||
} | ||
}); | ||
boost::asio::post( chain.get_thread_pool(), |
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 section of code is deep nested and becomes complicated. Can more comments be added and/or it be refactored a bit?
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.
Cleaned it up some.
Remove the use of a
std::future
andwait
in producer thread pool. Now after signature recovery is complete the chain thread posts directly to the main application thread. This improves the eosio token transfer per second (TPS) tests from ~31K TPS to ~36K TPS.Transaction now transitions from net-thread => chain-thread => main-thread.
Removing the thread hop to chain-thread and performing key recovery on the net thread is possible (net-thread => main-thread), but testing shows it easily overwhelms the main-thread. Instead I think we need to create a memory pool of trxs that the main thread can pull from instead of pushing low priority tasks for trx execution to the main thread. That would greatly reduce the contention on the app post call and on the main thread priority queue. See #1860
This builds off the improvement of #1846.
Removes
--producer-threads
option as there is now no use for the producer thread pool.Issue #1690