Logging changes to support spreader profiling.

This commit is contained in:
Pedro Pinto committed 2017-10-18 12:45:01 +00:00
1 parent 2083204673
commit 99650ca361
7 files changed
+30 -22

No files matched your search

@@ -108,9 +108,9 @@ int SocketConnection::write (WriteVec const&vec,size_t vec_size,size_t cid)
iv[i].iov_len = vec[i].second;
}
LOG(Latency,Info,"SocketConnection::write::pre_write {} {}", cid, utils::TimeStamp::now().to_uint64());
LOG(Latency,Info,"SocketConnection_write_pre_write {} {}", cid, utils::TimeStamp::now().to_uint64());
auto result = ::writev (_fd,iv,(int) vec_size);
LOG(Latency,Info,"SocketConnection::write::post_write {} {}", cid, utils::TimeStamp::now().to_uint64());
LOG(Latency,Info,"SocketConnection_write_post_write {} {}", cid, utils::TimeStamp::now().to_uint64());
if (_log && result >0) {
for (size_t i = 0; i < vec_size;i++)
_out_log.write (vec[i].first, vec[i].second);
@@ -160,7 +160,7 @@ CoreGateway::~CoreGateway ()
void CoreGateway::send (orderman::TickToTradeCorID cid, OutFIXPtr const &fix)
{
LOG(Latency,Info,"CoreGateway::send {} {}", cid, utils::TimeStamp::now().to_uint64());
LOG(Latency,Info,"CoreGateway_send {} {}", cid, utils::TimeStamp::now().to_uint64());
me->event_queue.enqueue (EventData (&CoreGateway::sync_send,cid,fix));
}
@@ -271,7 +271,7 @@ void CoreGateway::sync_stop (EventData const&)
void CoreGateway::sync_send (EventData const &ev)
{
LOG(Latency,Info,"CoreGateway::sync_send {} {}", ev.cid, utils::TimeStamp::now().to_uint64());
LOG(Latency,Info,"CoreGateway_sync_send {} {}", ev.cid, utils::TimeStamp::now().to_uint64());
switch (me->state)
{
case State::OFF:
+2 -2
View File
@@ -544,12 +544,12 @@ void Session::internal_send (orderman::TickToTradeCorID cid, OutFIXPtr const&msg
data_vec[i].second = s.size ();
}
LOG(Latency,Info,"Session::internal_send::pre_write {} {}", cid, utils::TimeStamp::now().to_uint64());
LOG(Latency,Info,"Session_internal_send_pre_write {} {}", cid, utils::TimeStamp::now().to_uint64());
if (me->connection.write (data_vec,msgs->fix.size (),cid) < 0) {
terminate_session (JetFIXError::CONNECTION_ERROR);
return;
}
LOG(Latency,Info,"Session::internal_send::post_write {} {}", cid, utils::TimeStamp::now().to_uint64());
LOG(Latency,Info,"Session_internal_send_post_write {} {}", cid, utils::TimeStamp::now().to_uint64());
me->last_sent_msg_timestamp = me->now ();
me->store.store (msgs);
msgs->set_ts (OutFIX::POST_STORE,utils::TimeStamp::now ());
@@ -315,7 +315,8 @@ void MDP3Listener::onDefinition(onixs::Handler&, const onixs::Security&, const o
//
// Book
void MDP3Listener::onBookUpdate(onixs::Handler&, const onixs::Security& sec, const onixs::ConsolidatedBook& book) {
// LOG(MarketData, Info, "Book update {}", sec.id());
LOG(Latency,Info, "onBookUpdate {} {}", (uint16_t) _latest_sequence , utils::TimeStamp::now().to_uint64());
auto data = _index.get_security(sec.id());
if (data == nullptr) return;
bts_assert(data->id == (uint32_t)sec.id());
@@ -50,9 +50,9 @@ public:
&book.ask()[0]) == md2::HandleReadResult::SUCCESS) {
book._security_key = SecurityKey(handle->key());
auto corid = handle->sequence();
LOG(Latency,Info,"MDSource {} {}", corid,utils::TimeStamp::now().to_uint64());
book_update.correlation_id = corid;
book_update_signal(book_update);
LOG(Latency,Info,"MDSource {} {}", corid,utils::TimeStamp::now().to_uint64());
}
}
}
@@ -98,7 +98,7 @@ void NativeOrderMan::on(event_grid::event::Init const&)
void NativeOrderMan::on(event::CreateNativeOrder const&create)
{
LOG(Latency,Info,"NativeOrderMan::onCreateNativeOrder_enter {} {}",
LOG(Latency,Info,"NativeOrderMan_onCreateNativeOrder_enter {} {}",
create.cid, utils::TimeStamp::now().to_uint64());
auto &order = *create.order;
@@ -131,7 +131,7 @@ void NativeOrderMan::on(event::CreateNativeOrder const&create)
auto buffer = get_fix_bufer();
order.encode_create(me->latest_timestamp,create.price,create.quantity,&buffer->fix[0]);
LOG(Latency,Info,"NativeOrderMan::onCreateNativeOrder_exit {} {}", create.cid,
LOG(Latency,Info,"NativeOrderMan_onCreateNativeOrder_exit {} {}", create.cid,
utils::TimeStamp::now().to_uint64());
gateway_msg_signal(event::OutGatewayMsg {create.cid,buffer});
break;
@@ -140,7 +140,7 @@ void NativeOrderMan::on(event::CreateNativeOrder const&create)
void NativeOrderMan::on(event::UpdateNativeOrder const&update)
{
LOG(Latency,Info,"NativeOrderMan::onUpdateNativeOrder_enter {} {}",
LOG(Latency,Info,"NativeOrderMan_onUpdateNativeOrder_enter {} {}",
update.cid, utils::TimeStamp::now().to_uint64());
auto &order = const_cast<NativeOrder&> (*update.order);
@@ -162,7 +162,7 @@ void NativeOrderMan::on(event::UpdateNativeOrder const&update)
auto buffer = get_fix_bufer();
order.encode_update(me->latest_timestamp,update.price,update.quantity,&buffer->fix[0]);
LOG(Latency,Info,"NativeOrderMan::onUpdateNativeOrder_exit {} {}",
LOG(Latency,Info,"NativeOrderMan_onUpdateNativeOrder_exit {} {}",
update.cid, utils::TimeStamp::now().to_uint64());
gateway_msg_signal(event::OutGatewayMsg {update.cid,buffer});
}
@@ -50,7 +50,7 @@ SpreaderOrder::SpreaderOrder(securities::ISecurityDB &db,
Price(os.spreader().price()), Quantity(os.spreader().quantity()), os.reject_msg())),
_state (State::START)
{
LOG(OrderMan, Diag, "recovered SpreaderOrder from state. state: {}", utils::pb::to_string(os));
LOG(OrderMan, Diag, "recovered SpreaderOrder {} from disk",os.order_key() );
}
SpreaderOrder::SpreaderOrder(securities::ISecurityDB& db,
@@ -130,7 +130,7 @@ void SpreaderOrder::on_disconnect()
void SpreaderOrder::on_update(const api::orderman::UpdateSpreaderOrder& u)
{
LOG(OrderMan,Diag,"on_update SpreaderOrder. order: {}",utils::pb::to_string(u));
LOG(OrderMan,Diag,"on_update SpreaderOrder: {}",key().value());
if (me->resurrected) return;
bool success = false;
if (_state == State::START)
@@ -174,9 +174,9 @@ void SpreaderOrder::on_update(const api::orderman::UpdateSpreaderOrder& u)
report_state ();
}
void SpreaderOrder::on_cancel(const api::orderman::CancelSpreaderOrder& c)
void SpreaderOrder::on_cancel(const api::orderman::CancelSpreaderOrder& )
{
LOG(OrderMan,Diag,"on_cancel SpreaderOrder. order: {}",utils::pb::to_string(c));
LOG(OrderMan,Diag,"on_cancel SpreaderOrder. order {}",key().value());
if (me->resurrected) return;
if (_state == State::START)
_transform_to_END();
@@ -197,10 +197,10 @@ void SpreaderOrder::on_cancel(const api::orderman::CancelSpreaderOrder& c)
void SpreaderOrder::on_book(TickToTradeCorID cid, Book const& book)
{
if (me->resurrected) return;
LOG(OrderMan, Diag, "on_book {} {}/{}",
book.security_key().value(),
book.bid()[0].price(),
book.ask()[0].price());
// LOG(OrderMan, Diag, "on_book {} {}/{}",
// book.security_key().value(),
// book.bid()[0].price(),
// book.ask()[0].price());
LOG(Latency, Info, "on_book {} {}", cid, utils::TimeStamp::now().to_uint64());
if (_state == State::START)
bts_assert(false);
@@ -252,9 +252,9 @@ void SpreaderOrder::on_child_update(OrderKey orderkey,
if (me->resurrected) return;
using namespace bts::spreader;
static std::string empty;
LOG(OrderMan,Diag, "SpreaderOrder.on_child_update "
"k: {} status: {} filled_qty: {} avg_price: {} reject_msg: {}",
LOG(OrderMan,Diag, "SpreaderOrder.on_child_update " "k: {} status: {} filled_qty: {} avg_price: {} reject_msg: {}",
orderkey.value(), status, filled_quantity.value(), average_price.value(), error_msg == nullptr ? empty : *error_msg);
if (_state == State::START)
bts_assert(false);
else if (_state == State::WAITING_FOR_FIRST_CONNECT)
@@ -264,6 +264,8 @@ void SpreaderOrder::on_child_update(OrderKey orderkey,
SpreaderLegData* leg_data_ptr = _bookkeeping_data->find_leg_from_quoter_orderkey(orderkey);
if (leg_data_ptr != nullptr)
{
LOG(OrderMan,Diag, "Order {} is a quoting order, forwarding", orderkey.value());
SpreaderLegData& leg_data = *(leg_data_ptr);
leg_data.order_update_message().update(status, filled_quantity, average_price, error_msg);
if (leg_data.order_update_message().has_error())
@@ -369,6 +371,11 @@ void SpreaderOrder::_init_state()
api::Security const * db_sec = me->db.resolve (leg_key);
bts::orderman::SpreaderOrderBase::ChildFactory child_factory = get_child_factory(*db_sec, leg_property_data.trading_side, api::orderman::ChildOrderKind::COK_SPREADER_QUOTING);
bts::orderman::SpreaderOrderBase::ChildOrder child_order = child_factory();
LOG(OrderMan,Diag,"Initiazing quoting order {} owned by spreader order {}",
child_order.order_key().value(),
key().value());
SingleLegQuoter leg_quoter(me_ref, leg_property_data, n_spreader_legs, Price(cor.price()), Quantity(cor.quantity()), child_order);
SpreaderLegData leg_data(leg_property_data, leg_quoter, child_order.order_key());
leg_data_vector.push_back(leg_data);