From b1e54864e9d488424883bb2ed422b163bcebce23 Mon Sep 17 00:00:00 2001 From: Jae Kim Date: Tue, 7 Mar 2017 15:21:41 -0800 Subject: [PATCH 1/5] Updated commit id of istio/proxy --- WORKSPACE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WORKSPACE b/WORKSPACE index f79aa20b7..175431519 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -26,7 +26,7 @@ # # A Bazel (http://bazel.io) workspace for the Google Cloud Endpoints runtime. -ISTIO_PROXY = "c815b890f6ac60e9dc57f80c97b1bccc9930c073" +ISTIO_PROXY = "cafe153d422c496a5ef12af73a597046fb025f12" git_repository( name = "nginx", From e67c67185c4ad8e7ce62eb5b73544623c97ccff9 Mon Sep 17 00:00:00 2001 From: Jae Kim Date: Tue, 7 Mar 2017 17:03:04 -0800 Subject: [PATCH 2/5] Fixed proto_pass_perf tool compilation error --- src/tools/proto_pass_perf.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tools/proto_pass_perf.cc b/src/tools/proto_pass_perf.cc index a68548800..dea1f520c 100644 --- a/src/tools/proto_pass_perf.cc +++ b/src/tools/proto_pass_perf.cc @@ -43,12 +43,15 @@ using google::api_manager::service_control::Proto; using ::google::api::servicecontrol::v1::CheckRequest; using ::google::api::servicecontrol::v1::CheckResponse; +using ::google::api::servicecontrol::v1::AllocateQuotaRequest; +using ::google::api::servicecontrol::v1::AllocateQuotaResponse; using ::google::api::servicecontrol::v1::ReportRequest; using ::google::api::servicecontrol::v1::ReportResponse; using ::google::protobuf::Arena; using ::google::protobuf::util::Status; using ::google::service_control_client::CheckAggregationOptions; +using ::google::service_control_client::QuotaAggregationOptions; using ::google::service_control_client::ReportAggregationOptions; using ::google::service_control_client::ServiceControlClient; using ::google::service_control_client::ServiceControlClientOptions; @@ -87,6 +90,7 @@ void FillReportRequestInfo(ReportRequestInfo* request) { int total_called_checks = 0; int total_called_reports = 0; +int total_called_quotas = 0; std::string request_text; // Compare the performance for passing Service Control Report protobuf to its @@ -103,10 +107,14 @@ int main() { CheckAggregationOptions(1000000 /*entries*/, 1000000 /* refresh_interval_ms */, 1000000 /*flush_interval_ms*/), + QuotaAggregationOptions(1000000 /*entries*/, + 1000000 /* refresh_interval_ms */), ReportAggregationOptions(1000000 /*entries*/, 1000000 /* refresh_interval_ms */)); options.check_transport = [](const CheckRequest&, CheckResponse*, TransportDoneFunc) { ++total_called_checks; }; + options.quota_transport = [](const AllocateQuotaRequest&, AllocateQuotaResponse*, + TransportDoneFunc) { ++total_called_quotas; }; options.report_transport = [](const ReportRequest&, ReportResponse*, TransportDoneFunc) { ++total_called_reports; }; client = CreateServiceControlClient(kServiceName, kServiceConfigId, options); From c8e5e4862f7ad04b7e1326d4698e461e6205162d Mon Sep 17 00:00:00 2001 From: Jae Kim Date: Tue, 7 Mar 2017 17:13:07 -0800 Subject: [PATCH 3/5] Fixed proto_pass_perf tool compilation error --- src/tools/proto_pass_perf.cc | 177 ----------------------------------- 1 file changed, 177 deletions(-) diff --git a/src/tools/proto_pass_perf.cc b/src/tools/proto_pass_perf.cc index dea1f520c..e69de29bb 100644 --- a/src/tools/proto_pass_perf.cc +++ b/src/tools/proto_pass_perf.cc @@ -1,177 +0,0 @@ -// Copyright (C) Extensible Service Proxy Authors -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -// SUCH DAMAGE. -// -//////////////////////////////////////////////////////////////////////////////// -// -#include -#include -#include -#include -#include -#include -#include - -#include "contrib/endpoints/src/api_manager/service_control/info.h" -#include "contrib/endpoints/src/api_manager/service_control/proto.h" -#include "google/protobuf/text_format.h" -#include "include/service_control_client.h" - -using google::api_manager::service_control::OperationInfo; -using google::api_manager::service_control::ReportRequestInfo; -using google::api_manager::service_control::Proto; - -using ::google::api::servicecontrol::v1::CheckRequest; -using ::google::api::servicecontrol::v1::CheckResponse; -using ::google::api::servicecontrol::v1::AllocateQuotaRequest; -using ::google::api::servicecontrol::v1::AllocateQuotaResponse; -using ::google::api::servicecontrol::v1::ReportRequest; -using ::google::api::servicecontrol::v1::ReportResponse; -using ::google::protobuf::Arena; -using ::google::protobuf::util::Status; - -using ::google::service_control_client::CheckAggregationOptions; -using ::google::service_control_client::QuotaAggregationOptions; -using ::google::service_control_client::ReportAggregationOptions; -using ::google::service_control_client::ServiceControlClient; -using ::google::service_control_client::ServiceControlClientOptions; -using ::google::service_control_client::TransportDoneFunc; - -namespace { - -const char kServiceName[] = "library.googleapis.com"; -const char kServiceConfigId[] = "2016-09-19r0"; -const int MAX_PROTO_PASS_SIZE = 1000000; - -} // namespace - -void FillOperationInfo(OperationInfo* op) { - op->operation_id = "operation_id"; - op->operation_name = "operation_name"; - op->api_key = "api_key_x"; - op->producer_project_id = "project_id"; -} - -void FillReportRequestInfo(ReportRequestInfo* request) { - request->referer = "referer"; - request->response_code = 200; - request->location = "us-central"; - request->api_name = "api-version"; - request->api_method = "api-method"; - request->request_size = 100; - request->response_size = 1024 * 1024; - request->log_message = "test-method is called"; - request->latency.request_time_ms = 123; - request->latency.backend_time_ms = 101; - request->latency.overhead_time_ms = 22; - request->auth_issuer = "auth-issuer"; - request->auth_audience = "auth-audience"; -} - -int total_called_checks = 0; -int total_called_reports = 0; -int total_called_quotas = 0; -std::string request_text; - -// Compare the performance for passing Service Control Report protobuf to its -// aggregator. -// 1. Allocate a new protobuf for each call. -// 2. Re-use protobuf from a pool. -// 3. Use proto arena allocation. -int main() { - Proto scp({"local_test_log"}, kServiceName, kServiceConfigId); - - std::unique_ptr client; - // To set the cache, flush interval large enough for this test. - ServiceControlClientOptions options( - CheckAggregationOptions(1000000 /*entries*/, - 1000000 /* refresh_interval_ms */, - 1000000 /*flush_interval_ms*/), - QuotaAggregationOptions(1000000 /*entries*/, - 1000000 /* refresh_interval_ms */), - ReportAggregationOptions(1000000 /*entries*/, - 1000000 /* refresh_interval_ms */)); - options.check_transport = [](const CheckRequest&, CheckResponse*, - TransportDoneFunc) { ++total_called_checks; }; - options.quota_transport = [](const AllocateQuotaRequest&, AllocateQuotaResponse*, - TransportDoneFunc) { ++total_called_quotas; }; - options.report_transport = [](const ReportRequest&, ReportResponse*, - TransportDoneFunc) { ++total_called_reports; }; - client = CreateServiceControlClient(kServiceName, kServiceConfigId, options); - - ReportRequestInfo info; - FillOperationInfo(&info); - FillReportRequestInfo(&info); - ReportResponse response; - - // 1. Allocate proto for each call. - std::clock_t start = std::clock(); - for (int i = 0; i < MAX_PROTO_PASS_SIZE; i++) { - std::unique_ptr request(new ReportRequest()); - scp.FillReportRequest(info, request.get()); - client->Report(*request, &response, [](Status status) {}); - } - - GOOGLE_LOG(INFO) << "Report 1 million requests time: " - << 1000.0 * (std::clock() - start) / CLOCKS_PER_SEC << "ms"; - GOOGLE_CHECK(total_called_reports == 0); - client = CreateServiceControlClient(kServiceName, kServiceConfigId, options); - GOOGLE_CHECK(total_called_reports == 1); - total_called_reports = 0; - - // 2. Reuse proto allocation. - std::clock_t start_reuse = std::clock(); - std::unique_ptr request_reuse(new ReportRequest()); - for (int i = 0; i < MAX_PROTO_PASS_SIZE; i++) { - scp.FillReportRequest(info, request_reuse.get()); - client->Report(*request_reuse, &response, [](Status status) {}); - request_reuse->Clear(); - } - - GOOGLE_LOG(INFO) << "Report 1 million requests reuse the proto: " - << 1000.0 * (std::clock() - start_reuse) / CLOCKS_PER_SEC - << "ms"; - GOOGLE_CHECK(total_called_reports == 0); - client = CreateServiceControlClient(kServiceName, kServiceConfigId, options); - // GOOGLE_CHECK(total_called_reports == 1) does not hold here. - total_called_reports = 0; - - // 3. Use proto arena allocation. - std::clock_t start_arena = std::clock(); - for (int i = 0; i < MAX_PROTO_PASS_SIZE; i++) { - std::unique_ptr arena(new Arena); - ReportRequest* request_arena = - Arena::CreateMessage(arena.get()); - scp.FillReportRequest(info, request_arena); - client->Report(*request_arena, &response, [](Status status) {}); - } - - GOOGLE_LOG(INFO) << "Report 1 million requests using arena:" - << 1000.0 * (std::clock() - start_arena) / CLOCKS_PER_SEC - << "ms"; - GOOGLE_CHECK(total_called_reports == 0); - client = CreateServiceControlClient(kServiceName, kServiceConfigId, options); - GOOGLE_CHECK(total_called_reports == 1); - - return 0; -} From f9a8fbacd6900db83e49176565cf2f3841362a81 Mon Sep 17 00:00:00 2001 From: Jae Kim Date: Tue, 7 Mar 2017 17:31:38 -0800 Subject: [PATCH 4/5] Recover codes acdientally removed --- src/nginx/module.cc | 5 +- src/tools/proto_pass_perf.cc | 178 +++++++++++++++++++++++++++++++++++ 2 files changed, 181 insertions(+), 2 deletions(-) diff --git a/src/nginx/module.cc b/src/nginx/module.cc index a22dd1870..3f5fe1096 100644 --- a/src/nginx/module.cc +++ b/src/nginx/module.cc @@ -830,8 +830,9 @@ ngx_int_t ngx_esp_create_http_configuration(ngx_conf_t *cf, ngx_memzero(ssl, sizeof(ngx_ssl_t)); ssl->log = cf->log; - if (ngx_ssl_create(ssl, NGX_SSL_SSLv2 | NGX_SSL_SSLv3 | NGX_SSL_TLSv1 | - NGX_SSL_TLSv1_1 | NGX_SSL_TLSv1_2, + if (ngx_ssl_create(ssl, + NGX_SSL_SSLv2 | NGX_SSL_SSLv3 | NGX_SSL_TLSv1 | + NGX_SSL_TLSv1_1 | NGX_SSL_TLSv1_2, nullptr) != NGX_OK) { return NGX_ERROR; } diff --git a/src/tools/proto_pass_perf.cc b/src/tools/proto_pass_perf.cc index e69de29bb..b890fc4c1 100644 --- a/src/tools/proto_pass_perf.cc +++ b/src/tools/proto_pass_perf.cc @@ -0,0 +1,178 @@ +// Copyright (C) Extensible Service Proxy Authors +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. +// +//////////////////////////////////////////////////////////////////////////////// +// +#include +#include +#include +#include +#include +#include +#include + +#include "contrib/endpoints/src/api_manager/service_control/info.h" +#include "contrib/endpoints/src/api_manager/service_control/proto.h" +#include "google/protobuf/text_format.h" +#include "include/service_control_client.h" + +using google::api_manager::service_control::OperationInfo; +using google::api_manager::service_control::ReportRequestInfo; +using google::api_manager::service_control::Proto; + +using ::google::api::servicecontrol::v1::CheckRequest; +using ::google::api::servicecontrol::v1::CheckResponse; +using ::google::api::servicecontrol::v1::AllocateQuotaRequest; +using ::google::api::servicecontrol::v1::AllocateQuotaResponse; +using ::google::api::servicecontrol::v1::ReportRequest; +using ::google::api::servicecontrol::v1::ReportResponse; +using ::google::protobuf::Arena; +using ::google::protobuf::util::Status; + +using ::google::service_control_client::CheckAggregationOptions; +using ::google::service_control_client::QuotaAggregationOptions; +using ::google::service_control_client::ReportAggregationOptions; +using ::google::service_control_client::ServiceControlClient; +using ::google::service_control_client::ServiceControlClientOptions; +using ::google::service_control_client::TransportDoneFunc; + +namespace { + +const char kServiceName[] = "library.googleapis.com"; +const char kServiceConfigId[] = "2016-09-19r0"; +const int MAX_PROTO_PASS_SIZE = 1000000; + +} // namespace + +void FillOperationInfo(OperationInfo* op) { + op->operation_id = "operation_id"; + op->operation_name = "operation_name"; + op->api_key = "api_key_x"; + op->producer_project_id = "project_id"; +} + +void FillReportRequestInfo(ReportRequestInfo* request) { + request->referer = "referer"; + request->response_code = 200; + request->location = "us-central"; + request->api_name = "api-version"; + request->api_method = "api-method"; + request->request_size = 100; + request->response_size = 1024 * 1024; + request->log_message = "test-method is called"; + request->latency.request_time_ms = 123; + request->latency.backend_time_ms = 101; + request->latency.overhead_time_ms = 22; + request->auth_issuer = "auth-issuer"; + request->auth_audience = "auth-audience"; +} + +int total_called_checks = 0; +int total_called_reports = 0; +int total_called_quotas = 0; +std::string request_text; + +// Compare the performance for passing Service Control Report protobuf to its +// aggregator. +// 1. Allocate a new protobuf for each call. +// 2. Re-use protobuf from a pool. +// 3. Use proto arena allocation. +int main() { + Proto scp({"local_test_log"}, kServiceName, kServiceConfigId); + + std::unique_ptr client; + // To set the cache, flush interval large enough for this test. + ServiceControlClientOptions options( + CheckAggregationOptions(1000000 /*entries*/, + 1000000 /* refresh_interval_ms */, + 1000000 /*flush_interval_ms*/), + QuotaAggregationOptions(1000000 /*entries*/, + 1000000 /* refresh_interval_ms */), + ReportAggregationOptions(1000000 /*entries*/, + 1000000 /* refresh_interval_ms */)); + options.check_transport = [](const CheckRequest&, CheckResponse*, + TransportDoneFunc) { ++total_called_checks; }; + options.quota_transport = [](const AllocateQuotaRequest&, + AllocateQuotaResponse*, + TransportDoneFunc) { ++total_called_quotas; }; + options.report_transport = [](const ReportRequest&, ReportResponse*, + TransportDoneFunc) { ++total_called_reports; }; + client = CreateServiceControlClient(kServiceName, kServiceConfigId, options); + + ReportRequestInfo info; + FillOperationInfo(&info); + FillReportRequestInfo(&info); + ReportResponse response; + + // 1. Allocate proto for each call. + std::clock_t start = std::clock(); + for (int i = 0; i < MAX_PROTO_PASS_SIZE; i++) { + std::unique_ptr request(new ReportRequest()); + scp.FillReportRequest(info, request.get()); + client->Report(*request, &response, [](Status status) {}); + } + + GOOGLE_LOG(INFO) << "Report 1 million requests time: " + << 1000.0 * (std::clock() - start) / CLOCKS_PER_SEC << "ms"; + GOOGLE_CHECK(total_called_reports == 0); + client = CreateServiceControlClient(kServiceName, kServiceConfigId, options); + GOOGLE_CHECK(total_called_reports == 1); + total_called_reports = 0; + + // 2. Reuse proto allocation. + std::clock_t start_reuse = std::clock(); + std::unique_ptr request_reuse(new ReportRequest()); + for (int i = 0; i < MAX_PROTO_PASS_SIZE; i++) { + scp.FillReportRequest(info, request_reuse.get()); + client->Report(*request_reuse, &response, [](Status status) {}); + request_reuse->Clear(); + } + + GOOGLE_LOG(INFO) << "Report 1 million requests reuse the proto: " + << 1000.0 * (std::clock() - start_reuse) / CLOCKS_PER_SEC + << "ms"; + GOOGLE_CHECK(total_called_reports == 0); + client = CreateServiceControlClient(kServiceName, kServiceConfigId, options); + // GOOGLE_CHECK(total_called_reports == 1) does not hold here. + total_called_reports = 0; + + // 3. Use proto arena allocation. + std::clock_t start_arena = std::clock(); + for (int i = 0; i < MAX_PROTO_PASS_SIZE; i++) { + std::unique_ptr arena(new Arena); + ReportRequest* request_arena = + Arena::CreateMessage(arena.get()); + scp.FillReportRequest(info, request_arena); + client->Report(*request_arena, &response, [](Status status) {}); + } + + GOOGLE_LOG(INFO) << "Report 1 million requests using arena:" + << 1000.0 * (std::clock() - start_arena) / CLOCKS_PER_SEC + << "ms"; + GOOGLE_CHECK(total_called_reports == 0); + client = CreateServiceControlClient(kServiceName, kServiceConfigId, options); + GOOGLE_CHECK(total_called_reports == 1); + + return 0; +} From ebdcff9101c122c128df300836a574d42e18e9b1 Mon Sep 17 00:00:00 2001 From: Jae Kim Date: Tue, 7 Mar 2017 17:39:42 -0800 Subject: [PATCH 5/5] Fixed code style --- src/nginx/module.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/nginx/module.cc b/src/nginx/module.cc index 3f5fe1096..a22dd1870 100644 --- a/src/nginx/module.cc +++ b/src/nginx/module.cc @@ -830,9 +830,8 @@ ngx_int_t ngx_esp_create_http_configuration(ngx_conf_t *cf, ngx_memzero(ssl, sizeof(ngx_ssl_t)); ssl->log = cf->log; - if (ngx_ssl_create(ssl, - NGX_SSL_SSLv2 | NGX_SSL_SSLv3 | NGX_SSL_TLSv1 | - NGX_SSL_TLSv1_1 | NGX_SSL_TLSv1_2, + if (ngx_ssl_create(ssl, NGX_SSL_SSLv2 | NGX_SSL_SSLv3 | NGX_SSL_TLSv1 | + NGX_SSL_TLSv1_1 | NGX_SSL_TLSv1_2, nullptr) != NGX_OK) { return NGX_ERROR; }