Skip to content

Commit

Permalink
Allow the dmclock library to handle the "cost" of an
Browse files Browse the repository at this point in the history
operation/request. This is in contrast to just measuring ops. If the
cost is set at the value 1, then it's equivalent to the old code.

The cost is calculated on the server side and affects the tag values
for the request. Furthermore, the cost is then sent back to the
client, so the ServiceTracker can use the cost to properly calculate
delta and rho values.

We now allow the delta and rho values sent with a request to be zero,
since the request cost is included on the server-side tag calculation,
and the request cost must be positive guaranteeing the advancement of
tags.

The OrigTracker has now been updated so as not to add one when
computing delta and rho.

The unit tests have been updated to use request costs. And the
simulator has been updated to use cost, and the cost of a client
group's requests can be configured.

The simulation has been changed to user the OrigTracker as the default
tracker.

Signed-off-by: J. Eric Ivancich <[email protected]>
  • Loading branch information
ivancich committed May 10, 2018
1 parent c7e4470 commit 17662d8
Show file tree
Hide file tree
Showing 16 changed files with 248 additions and 170 deletions.
15 changes: 14 additions & 1 deletion sim/dmc_sim_example.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[global]
server_groups = 1
client_groups = 3
client_groups = 4
server_random_selection = false
server_soft_limit = false

Expand Down Expand Up @@ -36,6 +36,19 @@ client_outstanding_ops = 32
client_reservation = 0.0
client_limit = 50.0
client_weight = 2.0
client_req_cost = 1

[client.3]
client_count = 1
client_wait = 10
client_total_ops = 2000
client_server_select_range = 1
client_iops_goal = 200
client_outstanding_ops = 32
client_reservation = 0.0
client_limit = 50.0
client_weight = 2.0
client_req_cost = 3

[server.0]
server_count = 1
Expand Down
2 changes: 2 additions & 0 deletions sim/src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ int crimson::qos_simulation::parse_config_file(const std::string &fname, sim_con
ct.client_limit = std::stod(val);
if (!cf.read(section, "client_weight", val))
ct.client_weight = std::stod(val);
if (!cf.read(section, "client_req_cost", val))
ct.client_req_cost = std::stoul(val);
g_conf.cli_group.push_back(ct);
}

Expand Down
10 changes: 7 additions & 3 deletions sim/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace crimson {
double client_reservation;
double client_limit;
double client_weight;
uint64_t client_req_cost;

cli_group_t(uint _client_count = 100,
uint _client_wait = 0,
Expand All @@ -46,7 +47,8 @@ namespace crimson {
uint _client_outstanding_ops = 100,
double _client_reservation = 20.0,
double _client_limit = 60.0,
double _client_weight = 1.0) :
double _client_weight = 1.0,
uint64_t _client_req_cost = 1u) :
client_count(_client_count),
client_wait(std::chrono::seconds(_client_wait)),
client_total_ops(_client_total_ops),
Expand All @@ -55,7 +57,8 @@ namespace crimson {
client_outstanding_ops(_client_outstanding_ops),
client_reservation(_client_reservation),
client_limit(_client_limit),
client_weight(_client_weight)
client_weight(_client_weight),
client_req_cost(_client_req_cost)
{
// empty
}
Expand All @@ -72,7 +75,8 @@ namespace crimson {
std::fixed << std::setprecision(1) <<
"client_reservation = " << cli_group.client_reservation << "\n" <<
"client_limit = " << cli_group.client_limit << "\n" <<
"client_weight = " << cli_group.client_weight;
"client_weight = " << cli_group.client_weight << "\n" <<
"client_req_cost = " << cli_group.client_req_cost;
return out;
}
}; // class cli_group_t
Expand Down
9 changes: 6 additions & 3 deletions sim/src/sim_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ namespace crimson {
TestResponse response;
ServerId server_id;
RespPm resp_params;
uint64_t request_cost;
};

const ClientId id;
Expand Down Expand Up @@ -202,9 +203,11 @@ namespace crimson {

void receive_response(const TestResponse& resp,
const ServerId& server_id,
const RespPm& resp_params) {
const RespPm& resp_params,
uint64_t request_cost) {
RespGuard g(mtx_resp);
resp_queue.push_back(RespQueueItem{resp, server_id, resp_params});
resp_queue.push_back(
RespQueueItem{ resp, server_id, resp_params, request_cost });
cv_resp.notify_one();
}

Expand Down Expand Up @@ -300,7 +303,7 @@ namespace crimson {
time_stats(internal_stats.mtx,
internal_stats.track_resp_time,
[&](){
service_tracker.track_resp(item.server_id, item.resp_params);
service_tracker.track_resp(item.server_id, item.resp_params, item.request_cost);
});
count_stats(internal_stats.mtx,
internal_stats.track_resp_count);
Expand Down
33 changes: 22 additions & 11 deletions sim/src/sim_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ namespace crimson {
ClientId client;
std::unique_ptr<TestRequest> request;
RespPm additional;
uint64_t request_cost;

QueueItem(const ClientId& _client,
std::unique_ptr<TestRequest>&& _request,
const RespPm& _additional) :
const RespPm& _additional,
uint64_t _request_cost) :
client(_client),
request(std::move(_request)),
additional(_additional)
additional(_additional),
request_cost(_request_cost)
{
// empty
}
Expand Down Expand Up @@ -69,7 +72,8 @@ namespace crimson {
using ClientRespFunc = std::function<void(ClientId,
const TestResponse&,
const ServerId&,
const RespPm&)>;
const RespPm&,
uint64_t)>;

using ServerAccumFunc = std::function<void(Accum& accumulator,
const RespPm& additional)>;
Expand Down Expand Up @@ -105,7 +109,7 @@ namespace crimson {

using CanHandleRequestFunc = std::function<bool(void)>;
using HandleRequestFunc =
std::function<void(const ClientId&,std::unique_ptr<TestRequest>,const RespPm&)>;
std::function<void(const ClientId&,std::unique_ptr<TestRequest>,const RespPm&, uint64_t)>;
using CreateQueueF = std::function<Q*(CanHandleRequestFunc,HandleRequestFunc)>;


Expand All @@ -122,7 +126,8 @@ namespace crimson {
this,
std::placeholders::_1,
std::placeholders::_2,
std::placeholders::_3))),
std::placeholders::_3,
std::placeholders::_4))),
client_resp_f(_client_resp_f),
iops(_iops),
thread_pool_size(_thread_pool_size),
Expand Down Expand Up @@ -156,13 +161,16 @@ namespace crimson {

void post(TestRequest&& request,
const ClientId& client_id,
const ReqPm& req_params)
const ReqPm& req_params,
uint64_t request_cost)
{
time_stats(internal_stats.mtx,
internal_stats.add_request_time,
[&](){
priority_queue->add_request(std::move(request),
client_id, req_params);
client_id,
req_params,
request_cost);
});
count_stats(internal_stats.mtx,
internal_stats.add_request_count);
Expand All @@ -181,13 +189,15 @@ namespace crimson {

void inner_post(const ClientId& client,
std::unique_ptr<TestRequest> request,
const RespPm& additional) {
const RespPm& additional,
uint64_t request_cost) {
Lock l(inner_queue_mtx);
assert(!finishing);
accum_f(accumulator, additional);
inner_queue.emplace_back(QueueItem(client,
std::move(request),
additional));
additional,
request_cost));
inner_queue_cv.notify_one();
}

Expand All @@ -202,17 +212,18 @@ namespace crimson {
auto client = front.client;
auto req = std::move(front.request);
auto additional = front.additional;
auto request_cost = front.request_cost;
inner_queue.pop_front();

l.unlock();

// simulation operation by sleeping; then call function to
// notify server of completion
std::this_thread::sleep_for(op_time);
std::this_thread::sleep_for(op_time * request_cost);

// TODO: rather than assuming this constructor exists, perhaps
// pass in a function that does this mapping?
client_resp_f(client, TestResponse{req->epoch}, id, additional);
client_resp_f(client, TestResponse{req->epoch}, id, additional, request_cost);

time_stats(internal_stats.mtx,
internal_stats.request_complete_time,
Expand Down
6 changes: 3 additions & 3 deletions sim/src/ssched/ssched_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ namespace crimson {
// emptry
}


void track_resp(const S& server_id, const NullData& ignore) {
void track_resp(const S& server_id,
const NullData& ignore,
uint64_t request_cost) {
// empty
}


/*
* Returns the ReqParams for the given server.
*/
Expand Down
12 changes: 7 additions & 5 deletions sim/src/ssched/ssched_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace crimson {
// a function to submit a request to the server; the second
// parameter is a callback when it's completed
using HandleRequestFunc =
std::function<void(const C&,RequestRef,NullData)>;
std::function<void(const C&,RequestRef,NullData,uint64_t)>;

struct PullReq {
enum class Type { returning, none };
Expand Down Expand Up @@ -111,14 +111,16 @@ namespace crimson {

void add_request(R&& request,
const C& client_id,
const ReqParams& req_params) {
const ReqParams& req_params,
uint64_t request_cost) {
add_request(RequestRef(new R(std::move(request))),
client_id, req_params);
client_id, req_params, request_cost);
}

void add_request(RequestRef&& request,
const C& client_id,
const ReqParams& req_params) {
const ReqParams& req_params,
uint64_t request_cost) {
DataGuard g(queue_mtx);

#ifdef PROFILE
Expand Down Expand Up @@ -183,7 +185,7 @@ namespace crimson {
if (!queue.empty() && can_handle_f()) {
auto& front = queue.front();
static NullData null_data;
handle_f(front.client, std::move(front.request), null_data);
handle_f(front.client, std::move(front.request), null_data, 1u);
queue.pop_front();
}
}
Expand Down
2 changes: 1 addition & 1 deletion sim/src/test_dmclock.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace crimson {
};

using DmcQueue = dmc::PushPriorityQueue<ClientId,sim::TestRequest>;
using DmcServiceTracker = dmc::ServiceTracker<ServerId,dmc::BorrowingTracker>;
using DmcServiceTracker = dmc::ServiceTracker<ServerId,dmc::OrigTracker>;

using DmcServer = sim::SimulatedServer<DmcQueue,
dmc::ReqParams,
Expand Down
25 changes: 16 additions & 9 deletions sim/src/test_dmclock_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ int main(int argc, char* argv[]) {
return i;
};

auto client_info_f = [=](const ClientId& c) -> const test::dmc::ClientInfo* {
auto client_info_f =
[=](const ClientId& c) -> const test::dmc::ClientInfo* {
return &client_info[ret_client_group_f(c)];
};

Expand All @@ -143,12 +144,16 @@ int main(int argc, char* argv[]) {

// lambda to post a request to the identified server; called by client
test::SubmitFunc server_post_f =
[&simulation](const ServerId& server,
sim::TestRequest&& request,
const ClientId& client_id,
const test::dmc::ReqParams& req_params) {
test::DmcServer& s = simulation->get_server(server);
s.post(std::move(request), client_id, req_params);
[&simulation,
&cli_group,
&ret_client_group_f](const ServerId& server,
sim::TestRequest&& request,
const ClientId& client_id,
const test::dmc::ReqParams& req_params) {
test::DmcServer& s = simulation->get_server(server);
uint64_t request_cost =
cli_group[ret_client_group_f(client_id)].client_req_cost;
s.post(std::move(request), client_id, req_params, request_cost);
};

std::vector<std::vector<sim::CliInst>> cli_inst;
Expand All @@ -175,10 +180,12 @@ int main(int argc, char* argv[]) {
[&simulation](ClientId client_id,
const sim::TestResponse& resp,
const ServerId& server_id,
const dmc::PhaseType& phase) {
const dmc::PhaseType& phase,
uint64_t request_cost) {
simulation->get_client(client_id).receive_response(resp,
server_id,
phase);
phase,
request_cost);
};

test::CreateQueueF create_queue_f =
Expand Down
8 changes: 5 additions & 3 deletions sim/src/test_ssched_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int main(int argc, char* argv[]) {
const ClientId& client_id,
const ssched::ReqParams& req_params) {
auto& server = simulation->get_server(server_id);
server.post(std::move(request), client_id, req_params);
server.post(std::move(request), client_id, req_params, 1u);
};

static std::vector<sim::CliInst> no_wait =
Expand All @@ -104,10 +104,12 @@ int main(int argc, char* argv[]) {
[&simulation](ClientId client_id,
const sim::TestResponse& resp,
const ServerId& server_id,
const ssched::NullData& resp_params) {
const ssched::NullData& resp_params,
uint64_t request_cost) {
simulation->get_client(client_id).receive_response(resp,
server_id,
resp_params);
resp_params,
request_cost);
};

test::CreateQueueF create_queue_f =
Expand Down
Loading

0 comments on commit 17662d8

Please sign in to comment.