diff --git a/rtbkit/core/banker/application_layer.cc b/rtbkit/core/banker/application_layer.cc index 6b62b244d..7f87d224f 100644 --- a/rtbkit/core/banker/application_layer.cc +++ b/rtbkit/core/banker/application_layer.cc @@ -158,7 +158,8 @@ syncAccount(const ShadowAccount &account, const std::string &shadowStr, void HttpLayer:: request(std::string method, const std::string &resource, - const RestParams ¶ms, const std::string &content, OnRequestResult onResult) + const RestParams ¶ms, const std::string &content, + const OnRequestResult & onResult) { std::transform(begin(method), end(method), begin(method), [](char c) { return ::tolower(c); }); @@ -315,7 +316,8 @@ syncAccount(const ShadowAccount &account, const std::string &shadowStr, void ZmqLayer:: request(std::string method, const std::string &resource, - const RestParams ¶ms, const std::string &content, OnRequestResult onResult) + const RestParams ¶ms, const std::string &content, + const OnRequestResult & onResult) { proxy->push(onResult, method, resource, params, content); } diff --git a/rtbkit/core/banker/application_layer.h b/rtbkit/core/banker/application_layer.h index 9d87a435a..0e1f99e57 100644 --- a/rtbkit/core/banker/application_layer.h +++ b/rtbkit/core/banker/application_layer.h @@ -71,11 +71,10 @@ struct ApplicationLayer : public MessageLoop { Account &&)> onDone) = 0; /* CUSTOM */ - virtual void request( - std::string method, const std::string &resource, - const RestParams ¶ms, - const std::string &content, - OnRequestResult onResult) = 0; + virtual void request(std::string method, const std::string &resource, + const RestParams ¶ms, + const std::string &content, + const OnRequestResult & onResult) = 0; }; /*****************************************************************************/ @@ -120,9 +119,9 @@ struct HttpLayer : public ApplicationLayer { Account &&)> onDone); void request(std::string method, const std::string &resource, - const RestParams ¶ms, - const std::string &content, - OnRequestResult onResult); + const RestParams ¶ms, + const std::string &content, + const OnRequestResult & onResult); private: std::shared_ptr httpClient; @@ -172,9 +171,9 @@ struct ZmqLayer : public ApplicationLayer { std::function onDone); void request(std::string method, const std::string &resource, - const RestParams ¶ms, - const std::string &content, - OnRequestResult onResult); + const RestParams ¶ms, + const std::string &content, + const OnRequestResult & onResult); private: std::shared_ptr proxy; diff --git a/rtbkit/core/banker/slave_banker.cc b/rtbkit/core/banker/slave_banker.cc index 5af6e0ab3..8c6194de7 100644 --- a/rtbkit/core/banker/slave_banker.cc +++ b/rtbkit/core/banker/slave_banker.cc @@ -159,7 +159,7 @@ init(const std::string & accountSuffix, CurrencyPool spendRate) std::placeholders::_1), true /* single threaded */); addPeriodic("SlaveBanker::reauthorizeBudget", 1.0, - std::bind(&SlaveBanker::reauthorizeBudget, + std::bind(&SlaveBanker::reauthorizeBudgetPeriodic, this, std::placeholders::_1), true /* single threaded */); @@ -408,56 +408,78 @@ reportSpend(uint64_t numTimeoutsExpired) void SlaveBanker:: -reauthorizeBudget(uint64_t numTimeoutsExpired) +reauthorizeBudgetPeriodic(uint64_t numTimeoutsExpired) { if (numTimeoutsExpired > 1) { cerr << "warning: slave banker missed " << numTimeoutsExpired << " timeouts" << endl; } - //std::unique_lock guard(lock); if (reauthorizing) { - cerr << "warning: reauthorize budget still in progress" << endl; + cerr << "warning: reauthorize budget still in progress (skipping)\n"; return; } - accountsLeft = 0; + auto onReauthorizedDone = [&] () { + reauthorizing = false; + numReauthorized++; + }; + reauthorizing = true; + reauthorizeBudget(onReauthorizedDone); +} - // For each of our accounts, we report back what has been spent - // and re-up to our desired float - auto onAccount = [&] (const AccountKey & key, - const ShadowAccount & account) - { - Json::Value payload = spendRate.toJson(); - auto onDone = std::bind(&SlaveBanker::onReauthorizeBudgetMessage, this, - key, - std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3); +void +SlaveBanker:: +reauthorizeBudget(const OnReauthorizeBudgetDone & onDone) +{ + //std::unique_lock guard(lock); - accountsLeft++; + // For each of our accounts, we report back what has been spent + // and re-up to our desired float - // Finally, send it out - applicationLayer->request( - "POST", "/v1/accounts/" + getShadowAccountStr(key) + "/balance", - { { "accountType", "spend" } }, - payload.toString(), - onDone); + auto reauthorizeOp = make_shared(); + reauthorizeOp->start = Date::now(); + reauthorizeOp->numAccounts = 0; + reauthorizeOp->pending = 0; + reauthorizeOp->onDone = onDone; + + auto onAccount + = [&] (const AccountKey & key, const ShadowAccount & account) { + reauthorizeOp->numAccounts++; + reauthorizeOp->pending++; + + // Finally, send it out + Json::Value payload = spendRate.toJson(); + auto onAccountDone = [=] (exception_ptr exc, int responseCode, + const string & payload) { + this->onReauthorizeBudgetMessage(key, exc, responseCode, payload); + reauthorizeOp->pending--; + if (reauthorizeOp->pending == 0) { + Date now = Date::now(); + if (reauthorizeOp->onDone) { + reauthorizeOp->onDone(); + } + } }; + + applicationLayer->request("POST", "/v1/accounts/" + getShadowAccountStr(key) + "/balance", + { { "accountType", "spend" } }, + payload.toString(), + onAccountDone); + }; accounts.forEachInitializedAccount(onAccount); - - if (accountsLeft > 0) { - reauthorizing = true; - reauthorizeDate = Date::now(); + if (reauthorizeOp->numAccounts == 0) { + if (reauthorizeOp->onDone) { + reauthorizeOp->onDone(); + } } } void SlaveBanker:: -onReauthorizeBudgetMessage(const AccountKey & accountKey, - std::exception_ptr exc, - int responseCode, - const std::string & payload) +onReauthorizeBudgetMessage(const AccountKey & accountKey, exception_ptr exc, + int responseCode, const string & payload) { if (exc) { cerr << "reauthorize budget got exception" << payload << endl; @@ -469,13 +491,6 @@ onReauthorizeBudgetMessage(const AccountKey & accountKey, Account masterAccount = Account::fromJson(Json::parse(payload)); accounts.syncFromMaster(accountKey, masterAccount); } - reauthorizeBudgetSent = Date(); - accountsLeft--; - if (accountsLeft == 0) { - lastReauthorizeDelay = Date::now() - reauthorizeDate; - numReauthorized++; - reauthorizing = false; - } } void diff --git a/rtbkit/core/banker/slave_banker.h b/rtbkit/core/banker/slave_banker.h index bdca9a64b..aa262a8ca 100644 --- a/rtbkit/core/banker/slave_banker.h +++ b/rtbkit/core/banker/slave_banker.h @@ -19,7 +19,6 @@ namespace RTBKIT { - /*****************************************************************************/ /* SLAVE BUDGET CONTROLLER */ /*****************************************************************************/ @@ -81,6 +80,7 @@ struct SlaveBudgetController budgetResultCallback(const SlaveBudgetController::OnBudgetResult & onResult); private: std::shared_ptr applicationLayer; + //std::shared_ptr httpClient; }; @@ -212,18 +212,11 @@ struct SlaveBanker : public Banker, public MessageLoop { void waitReauthorized() const; - size_t getNumReauthorized() - const + int getNumReauthorized() const { return numReauthorized; } - double getLastReauthorizeDelay() - const - { - return lastReauthorizeDelay; - } - /* Logging */ virtual void logBidEvents(const Datacratic::EventRecorder & eventRecorder) { @@ -246,16 +239,26 @@ struct SlaveBanker : public Banker, public MessageLoop { mutable Lock syncLock; Datacratic::Date lastSync; - /** Periodically we report spend to the banker.*/ void reportSpend(uint64_t numTimeoutsExpired); Date reportSpendSent; /** Periodically we ask the banker to re-authorize our budget. */ - void reauthorizeBudget(uint64_t numTimeoutsExpired); - Date reauthorizeBudgetSent; - CurrencyPool spendRate; + void reauthorizeBudgetPeriodic(uint64_t numTimeoutsExpired); + + typedef std::function OnReauthorizeBudgetDone; + void reauthorizeBudget(const OnReauthorizeBudgetDone & onDone = nullptr); + + struct ReauthorizeOp { + Date start; + int numAccounts; + std::atomic pending; + + OnReauthorizeBudgetDone onDone; + }; + + CurrencyPool spendRate; /// Called when we get an account status back from the master banker /// after a synchrnonization @@ -288,11 +291,8 @@ struct SlaveBanker : public Banker, public MessageLoop { std::atomic shutdown_; - std::atomic reauthorizing; - Date reauthorizeDate; - double lastReauthorizeDelay; - size_t numReauthorized; - size_t accountsLeft; + bool reauthorizing; + int numReauthorized; }; } // naemspace RTBKIT diff --git a/rtbkit/core/banker/testing/banker_bench.cc b/rtbkit/core/banker/testing/banker_bench.cc new file mode 100644 index 000000000..2223578c0 --- /dev/null +++ b/rtbkit/core/banker/testing/banker_bench.cc @@ -0,0 +1,258 @@ +/* banker_bench.cc + Wolfgang Sourdeau, 21 July 2014 + Copyright (c) 2014 Datacratic. All rights reserved. + + Benchmark "setBudget" by invoking using the HTTP services from the + MasterBanker from different clients and different transports. +*/ + +#include + +#include "jml/arch/timers.h" +#include "soa/service/message_loop.h" +#include "soa/service/rest_request_router.h" +#include "soa/service/http_client.h" +#include "soa/service/http_rest_proxy.h" +#include "soa/utils/benchmarks.h" + +#include "rtbkit/core/banker/master_banker.h" +#include "rtbkit/core/banker/slave_banker.h" + + +using namespace std; +using namespace Datacratic; +using namespace RTBKIT; + + +/* add an account */ +void addAccountSync(HttpClient & client, const AccountKey & account) +{ + int done(false), status(0); + + auto onResponse = [&] (const HttpRequest & rq, + HttpClientError error, + int newStatus, + string && headers, + string && body) { + status = newStatus; + done = true; + ML::futex_wake(done); + }; + auto cbs = make_shared(onResponse); + + string body("{" + " \"adjustmentLineItems\" : {}," + " \"adjustmentsIn\" : {}," + " \"adjustmentsOut\" : {}," + " \"allocatedIn\" : {}," + " \"allocatedOut\" : {}," + " \"budgetDecreases\" : {}," + " \"budgetIncreases\" : {}," + " \"commitmentsMade\" : {}," + " \"commitmentsRetired\" : {}," + " \"lineItems\" : {}," + " \"md\" : {" + " \"objectType\" : \"Account\"," + " \"version\" : 1" + " }," + " \"recycledIn\" : {}," + " \"recycledOut\" : {}," + " \"spent\" : {}," + " \"type\" : \"budget\"" + "}"); + HttpRequest::Content content(body, "application/json"); + + RestParams params{{"accountName", account.toString()}, + {"accountType", "budget"}}; + client.post("/v1/accounts", cbs, content, params); + while (!done) { + int oldDone(done); + ML::futex_wait(done, oldDone); + } + ExcAssert(status == 200); +} + +/* sets a budget of 100c MicroUSD, using the HttpClient class */ +void setBudgetSyncHC(HttpClient & client, const AccountKey & key, bool isPut) +{ + int done(false), status(0); + + auto onResponse = [&] (const HttpRequest & rq, + HttpClientError error, + int newStatus, + string && headers, + string && body) { + status = newStatus; + done = true; + ML::futex_wake(done); + }; + auto cbs = make_shared(onResponse); + + HttpRequest::Content content(string("{\"USD/1M\":1000000000}"), + "application/json"); + if (isPut) + client.put("/v1/accounts/" + key[0] + "/budget", cbs, content); + else + client.post("/v1/accounts/" + key[0] + "/budget", cbs, content); + while (!done) { + int oldDone(done); + ML::futex_wait(done, oldDone); + } + ExcAssert(status == 200); +} + +/* sets a budget of 100c MicroUSD, using the HttpClient class */ +void setBudgetSyncRP(HttpRestProxy & client, const AccountKey & key, + bool isPut) +{ + HttpRestProxy::Response response; + + HttpRestProxy::Content content(string("{\"USD/1M\":1000000000}"), + "application/json"); + if (isPut) + response = client.put(string("/v1/accounts/") + key[0] + "/budget", + content); + else + response = client.post(string("/v1/accounts/") + key[0] + "/budget", + content); + ExcAssert(response.code() == 200); +} + +/* sets a budget of X MicroUSD, using the RestProxy class */ +void setBudgetSyncZMQ(RestProxy & client, const AccountKey & key) +{ + int done(false), status(0); + + auto onDone = [&] (std::exception_ptr, + int newStatus, const std::string & body) { + status = newStatus; + done = true; + ML::futex_wake(done); + }; + + client.push(onDone, + "PUT", "/v1/accounts/" + key[0] + "/budget", + {}, string("{\"USD/1M\":1000000000}")); + while (!done) { + int oldDone(done); + ML::futex_wait(done, oldDone); + } + ExcAssert(status == 200); +} + +int main(int argc, char ** argv) +{ + size_t nAccounts(1); + { + char * envAccs = ::getenv("NUM_ACCOUNTS"); + if (envAccs) { + nAccounts = stoi(envAccs); + } + } + + cerr << ("Running benchmarks with num accounts = " + + to_string(nAccounts) + "\n"); + + Benchmarks bms; + shared_ptr bm; + + auto proxies = std::make_shared(); + + MessageLoop httpLoop; + httpLoop.start(); + + MasterBanker masterBanker(proxies, "masterBanker"); + + // Setup a master banker used to keep the canonical budget of the + // various bidding agent accounts. The data contained in this service is + // periodically persisted to redis. + masterBanker.init(std::make_shared()); + masterBanker.bindTcp(); + masterBanker.start(); + + ML::sleep(1); + + /* operations using async http client */ + { + auto client = make_shared("http://localhost:15000"); + httpLoop.addSource("httpClient", client); + client->waitConnectionState(AsyncEventSource::CONNECTED); + + for (int i = 0; i < nAccounts; i++) { + AccountKey key{"testCampaign" + to_string(i), + "testStrategy" + to_string(i)}; + addAccountSync(*client, key); + } + + cerr << "hc set budget put using HttpClient\n"; + bm.reset(new Benchmark(bms, "HttpClient-set-budget-put")); + for (int i = 0; i < nAccounts; i++) { + AccountKey key{"testCampaign" + to_string(i), + "testStrategy" + to_string(i)}; + setBudgetSyncHC(*client, key, true); + } + bm.reset(); + + cerr << "hc set budget post using HttpClient\n"; + bm.reset(new Benchmark(bms, "HttpClient-set-budget-post")); + for (int i = 0; i < nAccounts; i++) { + AccountKey key{"testCampaign" + to_string(i), + "testStrategy" + to_string(i)}; + setBudgetSyncHC(*client, key, false); + } + bm.reset(); + + httpLoop.removeSource(client.get()); + client->waitConnectionState(AsyncEventSource::DISCONNECTED); + } + + { + /* operations using http rest proxy */ + cerr << "rp set budget put using HttpRestProxy\n"; + bm.reset(new Benchmark(bms, "HttpRestProxy-set-budget-put")); + HttpRestProxy restProxy("http://localhost:15000"); + for (int i = 0; i < nAccounts; i++) { + AccountKey key{"testCampaign" + to_string(i), + "testStrategy" + to_string(i)}; + setBudgetSyncRP(restProxy, key, true); + } + bm.reset(); + + cerr << "hc set budget post using HttpRestProxy\n"; + bm.reset(new Benchmark(bms, "HttpRestProxy-set-budget-post")); + for (int i = 0; i < nAccounts; i++) { + AccountKey key{"testCampaign" + to_string(i), + "testStrategy" + to_string(i)}; + setBudgetSyncRP(restProxy, key, false); + } + bm.reset(); + } + + /* operations using zmq "rest" client */ + { + auto client = make_shared(); + httpLoop.addSource("zmqClient", client); + client->waitConnectionState(AsyncEventSource::CONNECTED); + client->init(proxies->config, "masterBanker"); + + cerr << "zmq set budget put using RestProxy\n"; + bm.reset(new Benchmark(bms, "RestProxy-set-budget-put")); + for (int i = 0; i < nAccounts; i++) { + AccountKey key{"testCampaign" + to_string(i), + "testStrategy" + to_string(i)}; + setBudgetSyncZMQ(*client, key); + } + bm.reset(); + + httpLoop.removeSource(client.get()); + client->waitConnectionState(AsyncEventSource::DISCONNECTED); + } + + bms.dumpTotals(); + + exit(0); + + // Test is done; clean up time. + // budgetController.shutdown(); + masterBanker.shutdown(); +} diff --git a/rtbkit/core/banker/testing/banker_testing.mk b/rtbkit/core/banker/testing/banker_testing.mk index de2214c2a..12bd27141 100644 --- a/rtbkit/core/banker/testing/banker_testing.mk +++ b/rtbkit/core/banker/testing/banker_testing.mk @@ -32,4 +32,6 @@ $(eval $(call test,banker_account_test,banker,boost)) $(eval $(call test,banker_behaviour_test,banker banker_temporary_server,boost manual)) $(eval $(call test,redis_persistence_test,banker,boost)) +$(eval $(call program,banker_bench,banker test_utils)) + banker_tests: master_banker_test slave_banker_test banker_account_test banker_behaviour_test redis_persistence_test diff --git a/rtbkit/examples/examples.mk b/rtbkit/examples/examples.mk index ff6982e8d..4337c5d7f 100644 --- a/rtbkit/examples/examples.mk +++ b/rtbkit/examples/examples.mk @@ -19,7 +19,7 @@ $(eval $(call program,adserver_endpoint,standard_adserver data_logger rtb_router $(eval $(call program,integration_endpoints,exchange standard_adserver data_logger rtb_router bidding_agent boost_program_options services)) RTBKIT_INTEGRATION_TEST_LINK := \ - rtb_router bidding_agent integration_test_utils monitor monitor_service augmentor_ex adserver_connector mock_bid_request mock_adserver + rtb_router bidding_agent integration_test_utils monitor monitor_service augmentor_ex adserver_connector mock_bid_request mock_adserver recoset_utils $(eval $(call test,rtbkit_integration_test,$(RTBKIT_INTEGRATION_TEST_LINK),boost)) diff --git a/rtbkit/examples/rtbkit_integration_test.cc b/rtbkit/examples/rtbkit_integration_test.cc index 7fa8049f4..151af2ded 100644 --- a/rtbkit/examples/rtbkit_integration_test.cc +++ b/rtbkit/examples/rtbkit_integration_test.cc @@ -7,20 +7,19 @@ #include -#include "augmentor_ex.h" - +// #include "jml/utils/rng.h" +// #include "jml/utils/pair_utils.h" +// #include "jml/utils/environment.h" +#include "jml/arch/timers.h" +#include "jml/utils/testing/watchdog.h" +#include "soa/service/testing/redis_temporary_server.h" +#include "soa/utils/benchmarks.h" #include "rtbkit/core/router/router.h" #include "rtbkit/core/post_auction/post_auction_service.h" #include "rtbkit/core/agent_configuration/agent_configuration_service.h" #include "rtbkit/core/banker/master_banker.h" #include "rtbkit/core/banker/slave_banker.h" #include "rtbkit/core/monitor/monitor_endpoint.h" -#include "jml/utils/rng.h" -#include "jml/utils/pair_utils.h" -#include "jml/utils/environment.h" -#include "jml/arch/timers.h" -#include "jml/utils/testing/watchdog.h" -#include "soa/service/testing/redis_temporary_server.h" #include "rtbkit/testing/generic_exchange_connector.h" #include "rtbkit/testing/mock_exchange.h" #include "rtbkit/testing/test_agent.h" @@ -29,10 +28,8 @@ #include "rtbkit/plugins/adserver/mock_win_source.h" #include "rtbkit/plugins/adserver/mock_event_source.h" #include "rtbkit/plugins/bid_request/mock_bid_source.h" -#include -#include -#include +#include "augmentor_ex.h" using namespace std; using namespace ML; @@ -41,8 +38,6 @@ using namespace Datacratic; using namespace RTBKIT; -const size_t numAccounts(50); /* number of accounts and agents */ - #define ZMQ_APP_LAYER 1 /******************************************************************************/ @@ -222,7 +217,7 @@ struct Components cerr << "done shutdown" << endl; } - void init(size_t numAgents) + void init(Benchmarks & bm, size_t numAgents) { const string agentUri = "tcp://127.0.0.1:1234"; @@ -248,19 +243,24 @@ struct Components // various bidding agent accounts. The data contained in this service is // periodically persisted to redis. masterBanker.init(std::make_shared(redis)); - auto bankerAddr = masterBanker.bindTcp().second; + masterBanker.bindTcp(); masterBanker.start(); - cerr << "bankerAddr: " + bankerAddr + "\n"; - ML::sleep(5); + ML::sleep(1); + + Json::Value value = proxies->config->getJson("masterBanker/http/tcp"); + string bankerAddr = value[0]["httpUri"].asString(); + cerr << " bankerAddr: " + bankerAddr + "\n"; // Setup a slave banker that we can use to manipulate and peak at the // budgets during the test. #if ZMQ_APP_LAYER budgetController.setApplicationLayer(make_application_layer(proxies->config)); #else - auto appLayer = make_application_layer("http://127.0.0.1:15500"); - budgetController.setApplicationLayer(appLayer); + { + auto appLayer = make_application_layer(bankerAddr); + budgetController.setApplicationLayer(appLayer); + } #endif budgetController.start(); @@ -272,8 +272,7 @@ struct Components #if ZMQ_APP_LAYER auto appLayer = make_application_layer(proxies->config); #else - cerr << "bankerAddr: " + bankerAddr + "\n"; - auto appLayer = make_application_layer("http://127.0.0.1:15500"); + auto appLayer = make_application_layer(bankerAddr); #endif res->setApplicationLayer(appLayer); res->start(); @@ -331,24 +330,37 @@ struct Components // Our bidding agent which listens to the bid request stream from all // available routers and decide who gets to see your awesome pictures of // kittens. + for (size_t i = 0; i < numAgents; i++) { + Benchmark agentBm(bm, "agent-setup"); + shared_ptr shortBm; + AccountKey key{"testCampaign" + to_string(i), "testStrategy" + to_string(i)}; + + shortBm.reset(new Benchmark(bm, "agent-constructor")); + auto agent = make_shared(proxies, "testAgent" + to_string(i), key); agents.push_back(agent); - + + shortBm.reset(new Benchmark(bm, "agent-init")); agent->init(); + shortBm.reset(new Benchmark(bm, "agent-start")); agent->start(); + shortBm.reset(new Benchmark(bm, "agent-configure")); agent->configure(); // Some extra customization for our agent to make it extra // special. See setupAgent for more details. + shortBm.reset(new Benchmark(bm, "agent-setupAgent")); setupAgent(*agent); + shortBm.reset(new Benchmark(bm, "agent-budget")); // Setup an initial budgeting for the test. allocateBudget(budgetController, key, USD(1000)); + shortBm.reset(); } // Our augmentor which does frequency capping for our agent. @@ -372,12 +384,22 @@ int main(int argc, char ** argv) { Watchdog watchdog(200.0); + size_t nAccounts(200); + // Controls the length of the test. enum { nExchangeThreads = 10, nBidRequestsPerThread = 100 }; + { + char * envAccs = ::getenv("NUM_ACCOUNTS"); + if (envAccs) { + nAccounts = stoi(envAccs); + cerr << " naccounts from env: " + to_string(nAccounts) + "\n"; + } + } + auto proxies = std::make_shared(); // If we had a zookeeper instance running, we could use it to do service @@ -389,12 +411,18 @@ int main(int argc, char ** argv) // we don't, ServiceProxies will just default to using a local equivalent. if (false) proxies->logToCarbon("carbon.rtbkit.org", "stats"); + Benchmarks bm; + shared_ptr componentsBm(new Benchmark(bm, {"components-constructor"})); Components components(proxies); + componentsBm.reset(new Benchmark(bm, {"components-init"})); + // Setups up the various component of the RTBKit stack. See // Components::init for more details. - components.init(numAccounts); + components.init(bm, nAccounts); + + componentsBm.reset(); // Syncing is done periodically so we have to wait a bit before the router // will have a budget available. Necessary because the bid request stream @@ -411,8 +439,11 @@ int main(int argc, char ** argv) ML::sleep(2.1); + bm.dumpTotals(); + cerr << "testing budgets\n"; - for (int i = 0; i < numAccounts; i++) { + for (int i = 0; i < nAccounts; i++) { + Benchmark budgetBm(bm, {"budget-tests"}); AccountKey key{"testCampaign" + to_string(i), "testStrategy" + to_string(i)}; testBudget(components.budgetController, key); @@ -446,7 +477,6 @@ int main(int argc, char ** argv) shared_ptr slave = static_pointer_cast(banker); cerr << ("banker rqs : " + label + " " + to_string(slave->getNumReauthorized()) - + " last delay: " + to_string(slave->getLastReauthorizeDelay()) + "\n"); }; @@ -456,6 +486,9 @@ int main(int argc, char ** argv) } cerr << "SHUTDOWN\n"; + + bm.dumpTotals(); + exit(0); // Test is done; clean up time. components.shutdown(); diff --git a/rtbkit/plugins/bidder_interface/agents_bidder_interface.cc b/rtbkit/plugins/bidder_interface/agents_bidder_interface.cc index 38ee81884..c275ed072 100644 --- a/rtbkit/plugins/bidder_interface/agents_bidder_interface.cc +++ b/rtbkit/plugins/bidder_interface/agents_bidder_interface.cc @@ -3,9 +3,9 @@ Copyright (c) 2011 Datacratic. All rights reserved. */ -#include "agents_bidder_interface.h" #include "rtbkit/common/messages.h" #include "rtbkit/core/router/router.h" +#include "agents_bidder_interface.h" using namespace Datacratic; using namespace RTBKIT; diff --git a/rtbkit/plugins/bidder_interface/bidder_interface.mk b/rtbkit/plugins/bidder_interface/bidder_interface.mk index a1cb17f2a..816b7a3f1 100644 --- a/rtbkit/plugins/bidder_interface/bidder_interface.mk +++ b/rtbkit/plugins/bidder_interface/bidder_interface.mk @@ -1,5 +1,8 @@ -$(eval $(call library,agents_bidder,agents_bidder_interface.cc,)) +$(eval $(call library,agents_bidder,agents_bidder_interface.cc,rtb_router)) $(eval $(call library,http_bidder,http_bidder_interface.cc,openrtb_bid_request)) -# the code loading the plugins above is part of librtb (bidder_interface.cc) -$(LIB)/librtb.so: $(LIB)/libagents_bidder.so $(LIB)/libhttp_bidder.so + +bidder_interface_plugins: $(LIB)/libagents_bidder.so $(LIB)/libhttp_bidder.so + + +.PHONY: bidder_interface_plugins