diff --git a/src/lib/orderman/orders/NativeOrder.cpp b/src/lib/orderman/orders/NativeOrder.cpp index b7abfcd07..be637b6d4 100644 --- a/src/lib/orderman/orders/NativeOrder.cpp +++ b/src/lib/orderman/orders/NativeOrder.cpp @@ -526,11 +526,16 @@ void NativeOrder::on_update(Price p, Quantity q, PerfTrace const &t) { me->update_quantity_bm = encoding.overwrite(me->update_quantity_bm, q.value(), quantity_sz()); + tracepoint(bts_trace, trace_order, (char *)"on_update.half_way", 0, + trace.md_sn, trace.order_key); + auto const &ts = me->services->get_time_str(); me->update_transact_time_bm = encoding.overwrite( me->update_transact_time_bm, &ts.value()[0], ts.value().size()); auto buffer = me->session_services->get_fix_buffer(); auto &stream = buffer->fix[0]; + tracepoint(bts_trace, trace_order, (char *)"on_update.before_new_msg", 0, + trace.md_sn, trace.order_key); auto &f = stream.new_msg(jetfix::MessageTypes::CancelReplace); f.append(me->update_encoding); stream.close(); diff --git a/src/lib/orderman/perf_analysis/lttng/trace.sh b/src/lib/orderman/perf_analysis/lttng/trace.sh index bcbda7576..f880e35d8 100755 --- a/src/lib/orderman/perf_analysis/lttng/trace.sh +++ b/src/lib/orderman/perf_analysis/lttng/trace.sh @@ -22,6 +22,6 @@ sleep $TRACE_DURATION lttng stop lttng destroy mkdir -p trace_data -babeltrace ~/lttng-traces/* > trace_data/raw_trace.txt +babeltrace --clock-seconds ~/lttng-traces/* > trace_data/raw_trace.txt diff --git a/src/lib/utils/PBUtils.h b/src/lib/utils/PBUtils.h index af760fd85..dff0d4da7 100755 --- a/src/lib/utils/PBUtils.h +++ b/src/lib/utils/PBUtils.h @@ -73,6 +73,9 @@ inline bool equal(google::protobuf::Timestamp const &t1, google::protobuf::Times return t1.seconds() == t2.seconds() && t1.nanos() == t2.nanos(); } +inline double to_double_time(google::protobuf::Timestamp const &t1) +{return t1.seconds() + t1.nanos()/1e9;} + #endif }}} diff --git a/src/server/sparkd/cmds/PrintHedgeOrders.cpp b/src/server/sparkd/cmds/PrintHedgeOrders.cpp index 3acf45c27..eb3cf8e32 100644 --- a/src/server/sparkd/cmds/PrintHedgeOrders.cpp +++ b/src/server/sparkd/cmds/PrintHedgeOrders.cpp @@ -1,36 +1,58 @@ #include "server/sparkd/cmds/PrintHedgeOrders.h" -#include "lib/persistence/SqliteStore.h" #include "lib/api/services/OrderService.pb.h" +#include "lib/persistence/SqliteStore.h" #include "lib/utils/PBUtils.h" namespace bts { namespace cmd { int PrintHedgeOrders::execute(std::vector const &) { - persistence::SqliteStore store("orders"); - auto all = store.retrieve_all()["orders"]; + persistence::SqliteStore order_store("orders"); + auto all_orders = order_store.retrieve_all()["orders"]; - std::cout << "order_key,time_to_completed" << "\n"; - api::orderman::OrderRecord rec; - for (auto const &kvp : all) - if (utils::pb::from_string(kvp.second, &rec)) { - auto &def = rec.def(); - auto &state = rec.state(); - if (rec.parent_key() && - def.custom_def().has_limit() && - def.sub_type() == api::orderman::OrderSubType::ORDER_SUB_TYPE_HEDGING_LEG) { - auto created = state.created().seconds()* 1e9 + state.created().nanos(); - auto updated = state.last_change().seconds()* 1e9 + state.last_change().nanos(); - std::cout << kvp.first << "," << (updated-created) / 1000 / 1000 / 1000 << "\n"; + std::map> fill_times; + persistence::SqliteStore fill_store("fills"); + auto all_fills = fill_store.retrieve_all()["fills"]; + for (auto const &kvp : all_fills) { + api::orderman::Fill fill_rec; + if (utils::pb::from_string(kvp.second, &fill_rec)) { + auto ts = utils::pb::to_double_time(fill_rec.timestamp()); + auto &p = fill_times[fill_rec.order_key()]; + auto &min_time = p.second; + if (min_time < ts) { + p.first = kvp.first; + min_time = ts; } } + } + + std::cout << "order_key,time_to_first_fill,fill_id" + << "\n"; + api::orderman::OrderRecord rec; + for (auto const &kvp : all_orders) + if (utils::pb::from_string(kvp.second, + &rec)) { + auto &def = rec.def(); + auto &state = rec.state(); + if (rec.parent_key() && def.custom_def().has_limit() && + def.sub_type() == + api::orderman::OrderSubType::ORDER_SUB_TYPE_HEDGING_LEG) { + auto create_ts = utils::pb::to_double_time(state.created()); + auto &first_fill = fill_times[rec.key()]; + auto delta = first_fill.second - create_ts; + if (first_fill.first.size()) + std::cout << kvp.first << "," << delta << "," + << first_fill.first << "\n"; + } + } + return 0; } -std::string PrintHedgeOrders::help(){ - return - "Print out order ids for all hedge orders" - "which were completed at least one second being created"; +std::string PrintHedgeOrders::help() { + return "Print out order ids for all hedge orders" + "which were completed at least one second being created"; } -}} +} // namespace cmd +} // namespace bts diff --git a/src/server/sparkd/cmds/QuickTest.cpp b/src/server/sparkd/cmds/QuickTest.cpp index c20dbedb6..f97740319 100644 --- a/src/server/sparkd/cmds/QuickTest.cpp +++ b/src/server/sparkd/cmds/QuickTest.cpp @@ -3,54 +3,25 @@ #include "lib/mercury/actors/PingPong.h" #include "lib/mercury/executor/Executor.h" +#include "lib/utils/thread_manager.h" #include namespace bts { namespace cmd { -void test_ping_pong_mercury2() -{ - using namespace mercury; - - Executor ex1; - Executor ex2; - - ex1.init_neighbours(std::vector {&ex2}); - ex2.init_neighbours(std::vector {&ex1}); - - ex1.spawn(); - //ex1.spawn(); - ex2.spawn(); - - auto t = std::thread([&ex2]() { - cpu_set_t cpuset; - CPU_ZERO(&cpuset); - CPU_SET(1, &cpuset); - pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - - while (true) - ex2.do_work(); - }); - - bts::sleep_for(2s); - - cpu_set_t cpuset; - CPU_ZERO(&cpuset); - CPU_SET(0, &cpuset); - pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - - while (true) { - ex1.do_work(); - bts::sleep_for(100ms); - } -} - - - int QuickTest::execute(std::vector const &) { - test_ping_pong_mercury2(); - return 0; + threading::configure_current_thread("busy_poll"); + std::set s; + for (int i = 0; i < 1<<23;i++) + s.insert(i); + + auto sum = 0; + for(;;) { + for (auto &b : s) + sum+=b; + } + return sum; } std::string QuickTest::help() { diff --git a/src/web/CMakeDeps.cmake b/src/web/CMakeDeps.cmake index 050dc8062..65f907171 100644 --- a/src/web/CMakeDeps.cmake +++ b/src/web/CMakeDeps.cmake @@ -1 +1 @@ -set(sources ../../externals/linux/include/google/protobuf/descriptor.proto;../../externals/linux/include/google/protobuf/timestamp.proto;../lib/api/apicore.proto;../lib/api/apigateway.proto;../lib/api/apioptions.proto;../lib/api/services/AdminService.proto;../lib/api/services/ApiUnitTestService.proto;../lib/api/services/ErrorReportService.proto;../lib/api/services/HelloService.proto;../lib/api/services/MarketDataAuxiliaryService.proto;../lib/api/services/MarketDataRelay.proto;../lib/api/services/OrderService.proto;../lib/api/services/OutOfProcessURLListener.proto;../lib/api/services/PersistenceService.proto;../lib/api/services/PositionService.proto;../lib/api/services/ShellDiagnosticService.proto;../lib/api/services/ShellLatencyService.proto;../lib/api/services/SyntheticSecurityService.proto;../lib/api/services/UserService.proto;../lib/domain_model/Security.proto;../lib/md/protos/co2.proto;../lib/sparkproto/SparkProtos.proto;api/build.sh;api/node_modules/cssstyle/scripts/run_tests.sh;api/node_modules/exit/test/fixtures/create-files.sh;api/node_modules/protobufjs/cli/node_modules/acorn-jsx/node_modules/acorn/bin/update_authors.sh;api/node_modules/watch/release.sh;api/quiet_build.sh;api/src/DynamicService.ts;api/src/ServiceContext.ts;api/src/bts_assert.ts;ui/src/Access.fs;ui/src/Accounts/ClipLimits.fs;ui/src/Accounts/ProductLimits.fs;ui/src/Accounts/SecurityLimits.fs;ui/src/Accounts/State.fs;ui/src/Accounts/Types.fs;ui/src/Accounts/View.fs;ui/src/App.fs;ui/src/Cmd.fs;ui/src/Controls/Button.fs;ui/src/Controls/DataGrid.fs;ui/src/Controls/Fields.fs;ui/src/Controls/Modal.fs;ui/src/Controls/ReactGrid.fs;ui/src/Controls/Table.fs;ui/src/Controls/nbsp.fs;ui/src/Global.fs;ui/src/Imports.fs;ui/src/Lens.fs;ui/src/Login/Login.fs;ui/src/Nav.fs;ui/src/State.fs;ui/src/Types.fs;ui/src/Users/State.fs;ui/src/Users/Types.fs;ui/src/Users/View.fs;ui/src/Util/EnumUtils.fs;ui/src/Util/JSMap.fs) \ No newline at end of file +set(sources ../../externals/linux/include/google/protobuf/descriptor.proto;../../externals/linux/include/google/protobuf/timestamp.proto;../lib/api/apicore.proto;../lib/api/apigateway.proto;../lib/api/apioptions.proto;../lib/api/services/AdminService.proto;../lib/api/services/ApiUnitTestService.proto;../lib/api/services/ErrorReportService.proto;../lib/api/services/HelloService.proto;../lib/api/services/MarketDataAuxiliaryService.proto;../lib/api/services/MarketDataRelay.proto;../lib/api/services/OrderService.proto;../lib/api/services/OutOfProcessURLListener.proto;../lib/api/services/PersistenceService.proto;../lib/api/services/PositionService.proto;../lib/api/services/ShellDiagnosticService.proto;../lib/api/services/ShellLatencyService.proto;../lib/api/services/SyntheticSecurityService.proto;../lib/api/services/UserService.proto;../lib/domain_model/Security.proto;../lib/md/protos/co2.proto;../lib/sparkproto/SparkProtos.proto;api/build.sh;api/node_modules/exit/test/fixtures/create-files.sh;api/node_modules/protobufjs/cli/node_modules/acorn-jsx/node_modules/acorn/bin/update_authors.sh;api/node_modules/watch/release.sh;api/quiet_build.sh;api/src/DynamicService.ts;api/src/ServiceContext.ts;api/src/bts_assert.ts;ui/src/Access.fs;ui/src/Accounts/ClipLimits.fs;ui/src/Accounts/ProductLimits.fs;ui/src/Accounts/SecurityLimits.fs;ui/src/Accounts/State.fs;ui/src/Accounts/Types.fs;ui/src/Accounts/View.fs;ui/src/App.fs;ui/src/Cmd.fs;ui/src/Controls/Button.fs;ui/src/Controls/DataGrid.fs;ui/src/Controls/Fields.fs;ui/src/Controls/Modal.fs;ui/src/Controls/ReactGrid.fs;ui/src/Controls/Table.fs;ui/src/Controls/nbsp.fs;ui/src/Global.fs;ui/src/Imports.fs;ui/src/Lens.fs;ui/src/Login/Login.fs;ui/src/Nav.fs;ui/src/State.fs;ui/src/Types.fs;ui/src/Users/State.fs;ui/src/Users/Types.fs;ui/src/Users/View.fs;ui/src/Util/EnumUtils.fs;ui/src/Util/JSMap.fs) \ No newline at end of file