diff options
author | Craig Tiller <ctiller@google.com> | 2017-01-20 18:11:52 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-20 18:11:52 -0800 |
commit | 5e01e2ac977655aa074faf7fde0a74298f5e4c55 (patch) | |
tree | 9acab9c5952f292683a6d474861e2997e2a9d664 /test/core/memory_usage | |
parent | c84725fd02dc58a819c8c4e8acdc321e81f44764 (diff) |
Revert "Metadata handling rewrite"
Diffstat (limited to 'test/core/memory_usage')
-rw-r--r-- | test/core/memory_usage/client.c | 51 | ||||
-rw-r--r-- | test/core/memory_usage/server.c | 28 |
2 files changed, 39 insertions, 40 deletions
diff --git a/test/core/memory_usage/client.c b/test/core/memory_usage/client.c index 0cab872014..f4432bf572 100644 --- a/test/core/memory_usage/client.c +++ b/test/core/memory_usage/client.c @@ -58,7 +58,8 @@ typedef struct { grpc_call *call; grpc_metadata_array initial_metadata_recv; grpc_status_code status; - grpc_slice details; + char *details; + size_t details_capacity; grpc_metadata_array trailing_metadata_recv; } fling_call; @@ -84,11 +85,9 @@ static void init_ping_pong_request(int call_idx) { op->data.recv_initial_metadata = &calls[call_idx].initial_metadata_recv; op++; - grpc_slice hostname = grpc_slice_from_static_string("localhost"); calls[call_idx].call = grpc_channel_create_call( - channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, - grpc_slice_from_static_string("/Reflector/reflectUnary"), &hostname, - gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, "/Reflector/reflectUnary", + "localhost", gpr_inf_future(GPR_CLOCK_REALTIME), NULL); GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(calls[call_idx].call, metadata_ops, @@ -108,6 +107,8 @@ static void finish_ping_pong_request(int call_idx) { &calls[call_idx].trailing_metadata_recv; op->data.recv_status_on_client.status = &calls[call_idx].status; op->data.recv_status_on_client.status_details = &calls[call_idx].details; + op->data.recv_status_on_client.status_details_capacity = + &calls[call_idx].details_capacity; op++; GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(calls[call_idx].call, @@ -117,13 +118,13 @@ static void finish_ping_pong_request(int call_idx) { grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); grpc_metadata_array_destroy(&calls[call_idx].initial_metadata_recv); grpc_metadata_array_destroy(&calls[call_idx].trailing_metadata_recv); - grpc_slice_unref(calls[call_idx].details); + gpr_free(calls[call_idx].details); grpc_call_destroy(calls[call_idx].call); calls[call_idx].call = NULL; } -static struct grpc_memory_counters send_snapshot_request(int call_idx, - grpc_slice call_type) { +static struct grpc_memory_counters send_snapshot_request( + int call_idx, const char *call_type) { grpc_metadata_array_init(&calls[call_idx].initial_metadata_recv); grpc_metadata_array_init(&calls[call_idx].trailing_metadata_recv); @@ -148,11 +149,12 @@ static struct grpc_memory_counters send_snapshot_request(int call_idx, &calls[call_idx].trailing_metadata_recv; op->data.recv_status_on_client.status = &calls[call_idx].status; op->data.recv_status_on_client.status_details = &calls[call_idx].details; + op->data.recv_status_on_client.status_details_capacity = + &calls[call_idx].details_capacity; op++; - grpc_slice hostname = grpc_slice_from_static_string("localhost"); calls[call_idx].call = grpc_channel_create_call( - channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, call_type, &hostname, + channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, call_type, "localhost", gpr_inf_future(GPR_CLOCK_REALTIME), NULL); GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch( calls[call_idx].call, snapshot_ops, @@ -182,8 +184,9 @@ static struct grpc_memory_counters send_snapshot_request(int call_idx, grpc_slice_unref(response); grpc_byte_buffer_reader_destroy(&reader); grpc_byte_buffer_destroy(response_payload_recv); - grpc_slice_unref(calls[call_idx].details); - calls[call_idx].details = grpc_empty_slice(); + gpr_free(calls[call_idx].details); + calls[call_idx].details = NULL; + calls[call_idx].details_capacity = 0; grpc_call_destroy(calls[call_idx].call); calls[call_idx].call = NULL; @@ -216,8 +219,9 @@ int main(int argc, char **argv) { gpr_cmdline_parse(cl, argc, argv); gpr_cmdline_destroy(cl); - for (size_t k = 0; k < GPR_ARRAY_SIZE(calls); k++) { - calls[k].details = grpc_empty_slice(); + for (int k = 0; k < (int)(sizeof(calls) / sizeof(fling_call)); k++) { + calls[k].details = NULL; + calls[k].details_capacity = 0; } cq = grpc_completion_queue_create(NULL); @@ -228,10 +232,10 @@ int main(int argc, char **argv) { int call_idx = 0; - struct grpc_memory_counters before_server_create = send_snapshot_request( - 0, grpc_slice_from_static_string("Reflector/GetBeforeSvrCreation")); - struct grpc_memory_counters after_server_create = send_snapshot_request( - 0, grpc_slice_from_static_string("Reflector/GetAfterSvrCreation")); + struct grpc_memory_counters before_server_create = + send_snapshot_request(0, "Reflector/GetBeforeSvrCreation"); + struct grpc_memory_counters after_server_create = + send_snapshot_request(0, "Reflector/GetAfterSvrCreation"); // warmup period for (call_idx = 0; call_idx < warmup_iterations; ++call_idx) { @@ -239,8 +243,7 @@ int main(int argc, char **argv) { } struct grpc_memory_counters server_benchmark_calls_start = - send_snapshot_request( - 0, grpc_slice_from_static_string("Reflector/SimpleSnapshot")); + send_snapshot_request(0, "Reflector/SimpleSnapshot"); struct grpc_memory_counters client_benchmark_calls_start = grpc_memory_counters_snapshot(); @@ -253,8 +256,8 @@ int main(int argc, char **argv) { struct grpc_memory_counters client_calls_inflight = grpc_memory_counters_snapshot(); - struct grpc_memory_counters server_calls_inflight = send_snapshot_request( - 0, grpc_slice_from_static_string("Reflector/DestroyCalls")); + struct grpc_memory_counters server_calls_inflight = + send_snapshot_request(0, "Reflector/DestroyCalls"); do { event = grpc_completion_queue_next( @@ -269,8 +272,8 @@ int main(int argc, char **argv) { finish_ping_pong_request(call_idx + 1); } - struct grpc_memory_counters server_calls_end = send_snapshot_request( - 0, grpc_slice_from_static_string("Reflector/SimpleSnapshot")); + struct grpc_memory_counters server_calls_end = + send_snapshot_request(0, "Reflector/SimpleSnapshot"); struct grpc_memory_counters client_channel_end = grpc_memory_counters_snapshot(); diff --git a/test/core/memory_usage/server.c b/test/core/memory_usage/server.c index e8774bd976..c0710930b0 100644 --- a/test/core/memory_usage/server.c +++ b/test/core/memory_usage/server.c @@ -110,8 +110,7 @@ static void send_status(void *tag) { status_op.op = GRPC_OP_SEND_STATUS_FROM_SERVER; status_op.data.send_status_from_server.status = GRPC_STATUS_OK; status_op.data.send_status_from_server.trailing_metadata_count = 0; - grpc_slice details = grpc_slice_from_static_string(""); - status_op.data.send_status_from_server.status_details = &details; + status_op.data.send_status_from_server.status_details = ""; GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch((*(fling_call *)tag).call, &status_op, 1, tag, NULL)); @@ -141,8 +140,7 @@ static void send_snapshot(void *tag, struct grpc_memory_counters *snapshot) { op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; op->data.send_status_from_server.status = GRPC_STATUS_OK; op->data.send_status_from_server.trailing_metadata_count = 0; - grpc_slice details = grpc_slice_from_static_string(""); - op->data.send_status_from_server.status_details = &details; + op->data.send_status_from_server.status_details = ""; op++; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; @@ -247,27 +245,25 @@ int main(int argc, char **argv) { switch (s->state) { case FLING_SERVER_NEW_REQUEST: request_call_unary(++next_call_idx); - if (0 == grpc_slice_str_cmp(s->call_details.method, - "/Reflector/reflectUnary")) { + if (0 == + strcmp(s->call_details.method, "/Reflector/reflectUnary")) { s->state = FLING_SERVER_SEND_INIT_METADATA; send_initial_metadata_unary(s); - } else if (0 == - grpc_slice_str_cmp(s->call_details.method, - "Reflector/GetBeforeSvrCreation")) { + } else if (0 == strcmp(s->call_details.method, + "Reflector/GetBeforeSvrCreation")) { s->state = FLING_SERVER_SEND_STATUS_SNAPSHOT; send_snapshot(s, &before_server_create); - } else if (0 == - grpc_slice_str_cmp(s->call_details.method, - "Reflector/GetAfterSvrCreation")) { + } else if (0 == strcmp(s->call_details.method, + "Reflector/GetAfterSvrCreation")) { s->state = FLING_SERVER_SEND_STATUS_SNAPSHOT; send_snapshot(s, &after_server_create); - } else if (0 == grpc_slice_str_cmp(s->call_details.method, - "Reflector/SimpleSnapshot")) { + } else if (0 == strcmp(s->call_details.method, + "Reflector/SimpleSnapshot")) { s->state = FLING_SERVER_SEND_STATUS_SNAPSHOT; current_snapshot = grpc_memory_counters_snapshot(); send_snapshot(s, ¤t_snapshot); - } else if (0 == grpc_slice_str_cmp(s->call_details.method, - "Reflector/DestroyCalls")) { + } else if (0 == strcmp(s->call_details.method, + "Reflector/DestroyCalls")) { s->state = FLING_SERVER_BATCH_SEND_STATUS_FLING_CALL; current_snapshot = grpc_memory_counters_snapshot(); send_snapshot(s, ¤t_snapshot); |