Added a few utilities for perf testing.

This commit is contained in:
Pedro Pinto committed 2018-10-29 17:56:44 +00:00
1 parent 7b0e3edfcf
commit 74f79a2f52
6 files changed
+64 -63

No files matched your search

+5
View File
@@ -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();
@@ -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
+3
View File
@@ -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
}}}
+42 -20
View File
@@ -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<std::string> 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<api::orderman::OrderRecord>(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<uint32_t, std::pair<std::string, double>> 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<api::orderman::Fill>(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<api::orderman::OrderRecord>(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
+12 -41
View File
@@ -3,54 +3,25 @@
#include "lib/mercury/actors/PingPong.h"
#include "lib/mercury/executor/Executor.h"
#include "lib/utils/thread_manager.h"
#include <iostream>
namespace bts {
namespace cmd {
void test_ping_pong_mercury2()
{
using namespace mercury;
Executor ex1;
Executor ex2;
ex1.init_neighbours(std::vector<Executor*> {&ex2});
ex2.init_neighbours(std::vector<Executor*> {&ex1});
ex1.spawn<Ping>();
//ex1.spawn<Pong>();
ex2.spawn<Pong>();
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<std::string> const &) {
test_ping_pong_mercury2();
return 0;
threading::configure_current_thread("busy_poll");
std::set<uint32_t> 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() {
+1 -1
View File
@@ -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)
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)