SPARK-2197 Add some MBO stats logged every 5 minutes
This commit is contained in:
1 parent
c923be6ced
commit
71d2e01187
3 files changed
+64
-3
No files matched your search
@@ -1,9 +1,13 @@
|
||||
#include "MBOProcessor.h"
|
||||
#include "lib/utils/Dispatcher.h"
|
||||
#include "lib/utils/ConcurrentPool.h"
|
||||
#include "lib/config/config.h"
|
||||
#include "lib/config/protos/toggles.pb.h"
|
||||
|
||||
#include <map>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
#include <tbb/concurrent_hash_map.h>
|
||||
|
||||
@@ -20,11 +24,50 @@ struct SecurityKeyHashCompare {
|
||||
}
|
||||
};
|
||||
|
||||
void print_pool_stats(const utils::ConcurrentPool<MBOSnapshot>& pool) {
|
||||
size_t count = 0;
|
||||
std::vector<int> bid_sz,ask_sz;
|
||||
pool.unsafe_iterate([&](const MBOSnapshot& s) {
|
||||
if (s.bids.size() > 0 || s.asks.size() > 0) {
|
||||
count++;
|
||||
bid_sz.push_back(s.bids.size());
|
||||
ask_sz.push_back(s.asks.size());
|
||||
}
|
||||
});
|
||||
|
||||
std::sort(bid_sz.begin(), bid_sz.end());
|
||||
std::sort(ask_sz.begin(), ask_sz.end());
|
||||
size_t bid_tot =0, ask_tot = 0;
|
||||
for(size_t i : bid_sz) { bid_tot += i; }
|
||||
for(size_t i : ask_sz) { ask_tot += i; }
|
||||
|
||||
std::stringstream bid_percentiles, ask_percentiles;
|
||||
for (double x : { 0.5, 0.75, 0.9, 0.95, 0.99 }) {
|
||||
size_t index = count * x;
|
||||
bid_percentiles << bid_sz[index] << " ";
|
||||
ask_percentiles << ask_sz[index] << " ";
|
||||
}
|
||||
bid_percentiles << bid_sz[count-1] << " ";
|
||||
ask_percentiles << ask_sz[count-1] << " ";
|
||||
LOG(md,Info,
|
||||
"MBO statistics: count: {} - %[50,75,90,95,99,100] bid: [{}] - ask: [{}]",
|
||||
count, bid_percentiles.str(), ask_percentiles.str());
|
||||
}
|
||||
|
||||
typedef tbb::concurrent_hash_map<SecurityKey, MBOSnapshot*, SecurityKeyHashCompare> MapType;
|
||||
struct MBOProcessorImpl {
|
||||
utils::ConcurrentPool<MBOSnapshot> pool;
|
||||
MapType snapshots;
|
||||
MBOProcessorImpl() : pool(2048,512), snapshots() {}
|
||||
utils::DispatcherTimer timer;
|
||||
MBOProcessorImpl() :
|
||||
pool(2048,512),
|
||||
snapshots(),
|
||||
timer(utils::Dispatcher::background(), 600*1000, [&]() { print_pool_stats(pool); })
|
||||
{
|
||||
if (config::get<config::toggles::MBOStats>().enabled()) {
|
||||
timer.start();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
Reference in new issue
Block a user