From ae49e4fbd9b3c69f4c4a86d5bd0a5178252633e4 Mon Sep 17 00:00:00 2001 From: Andrey Maksimov Date: Mon, 3 Jul 2023 12:18:47 +0300 Subject: [PATCH 1/9] Update Dart bench to 3.0 --- dart_grpc_bench/.dockerignore | 3 + dart_grpc_bench/Dockerfile | 32 +++++++ dart_grpc_bench/bin/server.dart | 53 ++++++++++ dart_grpc_bench/pubspec.lock | 165 ++++++++++++++++++++++++++++++++ dart_grpc_bench/pubspec.yaml | 9 ++ 5 files changed, 262 insertions(+) create mode 100644 dart_grpc_bench/.dockerignore create mode 100644 dart_grpc_bench/Dockerfile create mode 100644 dart_grpc_bench/bin/server.dart create mode 100644 dart_grpc_bench/pubspec.lock create mode 100644 dart_grpc_bench/pubspec.yaml diff --git a/dart_grpc_bench/.dockerignore b/dart_grpc_bench/.dockerignore new file mode 100644 index 00000000..91da415d --- /dev/null +++ b/dart_grpc_bench/.dockerignore @@ -0,0 +1,3 @@ +.dockerignore +Dockerfile +.dart_tool/ \ No newline at end of file diff --git a/dart_grpc_bench/Dockerfile b/dart_grpc_bench/Dockerfile new file mode 100644 index 00000000..8060dbe7 --- /dev/null +++ b/dart_grpc_bench/Dockerfile @@ -0,0 +1,32 @@ +FROM dart:3.0.5-sdk AS build + +WORKDIR /app +COPY dart_grpc_bench/pubspec.yaml /app/pubspec.yaml +COPY proto /app/proto + +RUN dart pub get +COPY dart_grpc_bench /app +# Ensure packages are still up-to-date if anything has changed +RUN dart pub get --offline +RUN apt update && apt install -y protobuf-compiler +RUN dart pub global activate protoc_plugin +RUN mkdir -p lib/src/generated + +RUN protoc --plugin=protoc-gen-dart=$HOME/.pub-cache/bin/protoc-gen-dart \ + --proto_path=/app/proto/helloworld \ + --dart_out=grpc:lib/src/generated \ + -Iproto /app/proto/helloworld/helloworld.proto + +RUN dart compile exe bin/server.dart -o bin/server + +# ENTRYPOINT [ "/usr/bin/dart", "/app/bin/server.dart" ] + +# Build minimal serving image from AOT-compiled `/server` and required system +# libraries and configuration files stored in `/runtime/` from the build stage. +FROM scratch +COPY --from=build /runtime/ / +COPY --from=build /app/bin/server /app/bin/ + +# Start server. +EXPOSE 50051 +CMD ["/app/bin/server"] \ No newline at end of file diff --git a/dart_grpc_bench/bin/server.dart b/dart_grpc_bench/bin/server.dart new file mode 100644 index 00000000..708a83b4 --- /dev/null +++ b/dart_grpc_bench/bin/server.dart @@ -0,0 +1,53 @@ +// Copyright (c) 2018, the gRPC project authors. Please see the AUTHORS file +// for details. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/// Dart implementation of the gRPC helloworld.Greeter server. +import 'dart:io'; +import 'dart:isolate'; + +import 'package:grpc/grpc.dart'; + +import 'package:helloworld/src/generated/helloworld.pbgrpc.dart'; + +class GreeterService extends GreeterServiceBase { + @override + Future sayHello(ServiceCall call, HelloRequest request) async { + return HelloReply()..response = request.request; + } +} + +Future main(List args) async { + Map env = Platform.environment; + final cpus = int.tryParse(env["GRPC_SERVER_CPUS"] ?? '1') ?? 1; + + if (cpus > 1) { + for (var serve = 0; serve < cpus; serve++) { + Isolate.spawn(_startServer, []); + } + } + // Bind one server in current Isolate + _startServer(); + + print('Server listening on port 50051...'); + await ProcessSignal.sigterm.watch().first; +} + +void _startServer([List? args]) async { + final server = Server.create( + services: [GreeterService()], + ); + await server.serve( + address: InternetAddress.anyIPv4, port: 50051, shared: true); +} diff --git a/dart_grpc_bench/pubspec.lock b/dart_grpc_bench/pubspec.lock new file mode 100644 index 00000000..6e546b5b --- /dev/null +++ b/dart_grpc_bench/pubspec.lock @@ -0,0 +1,165 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + archive: + dependency: transitive + description: + name: archive + sha256: d6347d54a2d8028e0437e3c099f66fdb8ae02c4720c1e7534c9f24c10351f85d + url: "https://pub.dev" + source: hosted + version: "3.3.6" + async: + dependency: "direct main" + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" + source: hosted + version: "2.11.0" + collection: + dependency: transitive + description: + name: collection + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + url: "https://pub.dev" + source: hosted + version: "1.17.1" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 + url: "https://pub.dev" + source: hosted + version: "3.0.2" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + googleapis_auth: + dependency: transitive + description: + name: googleapis_auth + sha256: "127b1bbd32170ab8312f503bd57f1d654d8e4039ddfbc63c027d3f7ade0eff74" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + grpc: + dependency: "direct main" + description: + name: grpc + sha256: "4e9bff1ebb4ff370cf471b1ab85007b408ade867dcc34b551eee7ee7da573002" + url: "https://pub.dev" + source: hosted + version: "3.2.2" + http: + dependency: transitive + description: + name: http + sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482" + url: "https://pub.dev" + source: hosted + version: "0.13.5" + http2: + dependency: transitive + description: + name: http2 + sha256: "58805ebc6513eed3b98ee0a455a8357e61d187bf2e0fdc1e53120770f78de258" + url: "https://pub.dev" + source: hosted + version: "2.0.1" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" + meta: + dependency: transitive + description: + name: meta + sha256: "12307e7f0605ce3da64cf0db90e5fcab0869f3ca03f76be6bb2991ce0a55e82b" + url: "https://pub.dev" + source: hosted + version: "1.9.0" + path: + dependency: transitive + description: + name: path + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" + source: hosted + version: "1.8.3" + pointycastle: + dependency: transitive + description: + name: pointycastle + sha256: db7306cf0249f838d1a24af52b5a5887c5bf7f31d8bb4e827d071dc0939ad346 + url: "https://pub.dev" + source: hosted + version: "3.6.2" + protobuf: + dependency: "direct main" + description: + name: protobuf + sha256: "4034a02b7e231e7e60bff30a8ac13a7347abfdac0798595fae0b90a3f0afe759" + url: "https://pub.dev" + source: hosted + version: "3.0.0" + source_span: + dependency: transitive + description: + name: source_span + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.dev" + source: hosted + version: "1.9.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" + url: "https://pub.dev" + source: hosted + version: "1.3.1" +sdks: + dart: ">=3.0.5 <4.0.0" diff --git a/dart_grpc_bench/pubspec.yaml b/dart_grpc_bench/pubspec.yaml new file mode 100644 index 00000000..8b194cb3 --- /dev/null +++ b/dart_grpc_bench/pubspec.yaml @@ -0,0 +1,9 @@ +name: helloworld + +environment: + sdk: ^3.0.5 + +dependencies: + async: ^2.11.0 + grpc: ^3.2.0 + protobuf: ^3.0.0 From 2a760daf4d7693226d93381ee601c8e621984d9b Mon Sep 17 00:00:00 2001 From: Andrey Maksimov Date: Mon, 3 Jul 2023 15:53:00 +0300 Subject: [PATCH 2/9] Squash multiple RUN-s into one --- dart_grpc_bench/Dockerfile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dart_grpc_bench/Dockerfile b/dart_grpc_bench/Dockerfile index 8060dbe7..8e238719 100644 --- a/dart_grpc_bench/Dockerfile +++ b/dart_grpc_bench/Dockerfile @@ -2,15 +2,16 @@ FROM dart:3.0.5-sdk AS build WORKDIR /app COPY dart_grpc_bench/pubspec.yaml /app/pubspec.yaml -COPY proto /app/proto - RUN dart pub get + +COPY proto /app/proto COPY dart_grpc_bench /app + # Ensure packages are still up-to-date if anything has changed -RUN dart pub get --offline -RUN apt update && apt install -y protobuf-compiler -RUN dart pub global activate protoc_plugin -RUN mkdir -p lib/src/generated +RUN dart pub get --offline \ + && apt update && apt install -y protobuf-compiler \ + && dart pub global activate protoc_plugin \ + && mkdir -p lib/src/generated RUN protoc --plugin=protoc-gen-dart=$HOME/.pub-cache/bin/protoc-gen-dart \ --proto_path=/app/proto/helloworld \ From 52256dd91069abd06e2db467a1e734277333f9fd Mon Sep 17 00:00:00 2001 From: Andrey Maksimov Date: Mon, 3 Jul 2023 23:01:28 +0300 Subject: [PATCH 3/9] Add dart to CI action --- .github/workflows/build.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 738efe16..58a7730d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -204,6 +204,42 @@ jobs: GRPC_IMAGE_NAME: ${{ needs.set-image-name.outputs.name }} + dart_grpc_bench: + runs-on: ubuntu-latest + needs: + - set-image-name + - changed + if: fromJSON(needs.changed.outputs.base) || contains(needs.changed.outputs.files, 'dart_grpc_bench/') + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Build dart_grpc_bench + run: ./build.sh dart_grpc_bench + env: + GRPC_IMAGE_NAME: ${{ needs.set-image-name.outputs.name }} + + - name: Benchmark dart_grpc_bench + run: ./bench.sh dart_grpc_bench + env: + GRPC_BENCHMARK_DURATION: 30s + GRPC_IMAGE_NAME: ${{ needs.set-image-name.outputs.name }} + + - if: github.ref == 'refs/heads/master' + name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - if: github.ref == 'refs/heads/master' + name: If on master push image to GHCR + run: docker push $GRPC_IMAGE_NAME:dart_grpc_bench-complex_proto + env: + GRPC_IMAGE_NAME: ${{ needs.set-image-name.outputs.name }} + + d_grpc_bench: runs-on: ubuntu-latest needs: From 959f2405e5e82d5d6747625b37d8b02dbfbe36dc Mon Sep 17 00:00:00 2001 From: Andrey Maksimov Date: Mon, 18 Sep 2023 17:23:47 +0300 Subject: [PATCH 4/9] update dart deps --- dart_grpc_bench/pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dart_grpc_bench/pubspec.yaml b/dart_grpc_bench/pubspec.yaml index 8b194cb3..91c27aed 100644 --- a/dart_grpc_bench/pubspec.yaml +++ b/dart_grpc_bench/pubspec.yaml @@ -5,5 +5,5 @@ environment: dependencies: async: ^2.11.0 - grpc: ^3.2.0 - protobuf: ^3.0.0 + grpc: ^3.2.4 + protobuf: ^3.1.0 From 017c6bf2dc9b1a566f22ce6508c048d866e4155d Mon Sep 17 00:00:00 2001 From: Andrey Maksimov Date: Mon, 18 Sep 2023 17:47:04 +0300 Subject: [PATCH 5/9] Move dart after d in CI build file --- .github/workflows/build.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 58a7730d..6d7ca572 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -204,23 +204,23 @@ jobs: GRPC_IMAGE_NAME: ${{ needs.set-image-name.outputs.name }} - dart_grpc_bench: + d_grpc_bench: runs-on: ubuntu-latest needs: - set-image-name - changed - if: fromJSON(needs.changed.outputs.base) || contains(needs.changed.outputs.files, 'dart_grpc_bench/') + if: fromJSON(needs.changed.outputs.base) || contains(needs.changed.outputs.files, 'd_grpc_bench/') steps: - name: Checkout uses: actions/checkout@v3 - - name: Build dart_grpc_bench - run: ./build.sh dart_grpc_bench + - name: Build d_grpc_bench + run: ./build.sh d_grpc_bench env: GRPC_IMAGE_NAME: ${{ needs.set-image-name.outputs.name }} - - name: Benchmark dart_grpc_bench - run: ./bench.sh dart_grpc_bench + - name: Benchmark d_grpc_bench + run: ./bench.sh d_grpc_bench env: GRPC_BENCHMARK_DURATION: 30s GRPC_IMAGE_NAME: ${{ needs.set-image-name.outputs.name }} @@ -235,28 +235,28 @@ jobs: - if: github.ref == 'refs/heads/master' name: If on master push image to GHCR - run: docker push $GRPC_IMAGE_NAME:dart_grpc_bench-complex_proto + run: docker push $GRPC_IMAGE_NAME:d_grpc_bench-complex_proto env: GRPC_IMAGE_NAME: ${{ needs.set-image-name.outputs.name }} - d_grpc_bench: + dart_grpc_bench: runs-on: ubuntu-latest needs: - set-image-name - changed - if: fromJSON(needs.changed.outputs.base) || contains(needs.changed.outputs.files, 'd_grpc_bench/') + if: fromJSON(needs.changed.outputs.base) || contains(needs.changed.outputs.files, 'dart_grpc_bench/') steps: - name: Checkout uses: actions/checkout@v3 - - name: Build d_grpc_bench - run: ./build.sh d_grpc_bench + - name: Build dart_grpc_bench + run: ./build.sh dart_grpc_bench env: GRPC_IMAGE_NAME: ${{ needs.set-image-name.outputs.name }} - - name: Benchmark d_grpc_bench - run: ./bench.sh d_grpc_bench + - name: Benchmark dart_grpc_bench + run: ./bench.sh dart_grpc_bench env: GRPC_BENCHMARK_DURATION: 30s GRPC_IMAGE_NAME: ${{ needs.set-image-name.outputs.name }} @@ -271,7 +271,7 @@ jobs: - if: github.ref == 'refs/heads/master' name: If on master push image to GHCR - run: docker push $GRPC_IMAGE_NAME:d_grpc_bench-complex_proto + run: docker push $GRPC_IMAGE_NAME:dart_grpc_bench-complex_proto env: GRPC_IMAGE_NAME: ${{ needs.set-image-name.outputs.name }} From 3015b82a0788fbc44b27dfa117a3369f09ab249d Mon Sep 17 00:00:00 2001 From: Andrey Maksimov Date: Tue, 19 Sep 2023 11:20:06 +0300 Subject: [PATCH 6/9] Remove old dart benchmark --- dart_grpc_onhold/.dockerignore | 3 - dart_grpc_onhold/Dockerfile | 28 ------ dart_grpc_onhold/bin/server.dart | 52 ---------- dart_grpc_onhold/pubspec.lock | 165 ------------------------------- dart_grpc_onhold/pubspec.yaml | 9 -- 5 files changed, 257 deletions(-) delete mode 100644 dart_grpc_onhold/.dockerignore delete mode 100644 dart_grpc_onhold/Dockerfile delete mode 100644 dart_grpc_onhold/bin/server.dart delete mode 100644 dart_grpc_onhold/pubspec.lock delete mode 100644 dart_grpc_onhold/pubspec.yaml diff --git a/dart_grpc_onhold/.dockerignore b/dart_grpc_onhold/.dockerignore deleted file mode 100644 index 91da415d..00000000 --- a/dart_grpc_onhold/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -.dockerignore -Dockerfile -.dart_tool/ \ No newline at end of file diff --git a/dart_grpc_onhold/Dockerfile b/dart_grpc_onhold/Dockerfile deleted file mode 100644 index 850b398b..00000000 --- a/dart_grpc_onhold/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -FROM dart:2.19.4 AS build - -WORKDIR /app -COPY dart_grpc_bench/pubspec.yaml /app/pubspec.yaml -COPY proto /app/proto - -RUN dart pub get -COPY dart_grpc_bench /app -# Ensure packages are still up-to-date if anything has changed -RUN dart pub get --offline -RUN apt update && apt install -y protobuf-compiler -RUN dart pub global activate protoc_plugin -RUN mkdir -p lib/src/generated -RUN protoc --plugin=protoc-gen-dart=$HOME/.pub-cache/bin/protoc-gen-dart --proto_path=/app/proto/helloworld --dart_out=grpc:lib/src/generated -Iproto /app/proto/helloworld/helloworld.proto - -RUN dart compile exe bin/server.dart -o bin/server - -# ENTRYPOINT [ "/usr/bin/dart", "/app/bin/server.dart" ] - -# Build minimal serving image from AOT-compiled `/server` and required system -# libraries and configuration files stored in `/runtime/` from the build stage. -FROM scratch -COPY --from=build /runtime/ / -COPY --from=build /app/bin/server /app/bin/ - -# Start server. -EXPOSE 50051 -CMD ["/app/bin/server"] \ No newline at end of file diff --git a/dart_grpc_onhold/bin/server.dart b/dart_grpc_onhold/bin/server.dart deleted file mode 100644 index ced7ed45..00000000 --- a/dart_grpc_onhold/bin/server.dart +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2018, the gRPC project authors. Please see the AUTHORS file -// for details. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/// Dart implementation of the gRPC helloworld.Greeter server. -import 'dart:io'; -import 'dart:isolate'; - -import 'package:grpc/grpc.dart'; - -import 'package:helloworld/src/generated/helloworld.pb.dart'; -import 'package:helloworld/src/generated/helloworld.pbgrpc.dart'; - -class GreeterService extends GreeterServiceBase { - @override - Future sayHello(ServiceCall call, HelloRequest request) async { - return HelloReply()..response = request.request; - } -} - -Future main(List args) async { - Map env = Platform.environment; - final cpus = int.tryParse(env["GRPC_SERVER_CPUS"] ?? '1') ?? 1; - - if (cpus > 1) { - for (var serve = 0; serve < cpus; serve++) { - Isolate.spawn(_startServer, []); - } - } - // Bind one server in current Isolate - _startServer(); - - print('Server listening on port 50051...'); - await ProcessSignal.sigterm.watch().first; -} - -void _startServer([List? args]) async { - final server = Server([GreeterService()]); - await server.serve( - address: InternetAddress.anyIPv4, port: 50051, shared: true); -} diff --git a/dart_grpc_onhold/pubspec.lock b/dart_grpc_onhold/pubspec.lock deleted file mode 100644 index e5e21b8c..00000000 --- a/dart_grpc_onhold/pubspec.lock +++ /dev/null @@ -1,165 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - archive: - dependency: transitive - description: - name: archive - sha256: d6347d54a2d8028e0437e3c099f66fdb8ae02c4720c1e7534c9f24c10351f85d - url: "https://pub.dev" - source: hosted - version: "3.3.6" - async: - dependency: "direct main" - description: - name: async - sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 - url: "https://pub.dev" - source: hosted - version: "2.10.0" - collection: - dependency: transitive - description: - name: collection - sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" - url: "https://pub.dev" - source: hosted - version: "1.17.1" - convert: - dependency: transitive - description: - name: convert - sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" - url: "https://pub.dev" - source: hosted - version: "3.1.1" - crypto: - dependency: transitive - description: - name: crypto - sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 - url: "https://pub.dev" - source: hosted - version: "3.0.2" - fixnum: - dependency: transitive - description: - name: fixnum - sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" - url: "https://pub.dev" - source: hosted - version: "1.1.0" - googleapis_auth: - dependency: transitive - description: - name: googleapis_auth - sha256: "127b1bbd32170ab8312f503bd57f1d654d8e4039ddfbc63c027d3f7ade0eff74" - url: "https://pub.dev" - source: hosted - version: "1.3.1" - grpc: - dependency: "direct main" - description: - name: grpc - sha256: a73c16e4f6a4a819be892bb2c73cc1d0b00e36095f69b0738cc91a733e3d27ba - url: "https://pub.dev" - source: hosted - version: "3.1.0" - http: - dependency: transitive - description: - name: http - sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482" - url: "https://pub.dev" - source: hosted - version: "0.13.5" - http2: - dependency: transitive - description: - name: http2 - sha256: "58805ebc6513eed3b98ee0a455a8357e61d187bf2e0fdc1e53120770f78de258" - url: "https://pub.dev" - source: hosted - version: "2.0.1" - http_parser: - dependency: transitive - description: - name: http_parser - sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" - url: "https://pub.dev" - source: hosted - version: "4.0.2" - js: - dependency: transitive - description: - name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 - url: "https://pub.dev" - source: hosted - version: "0.6.7" - meta: - dependency: transitive - description: - name: meta - sha256: "12307e7f0605ce3da64cf0db90e5fcab0869f3ca03f76be6bb2991ce0a55e82b" - url: "https://pub.dev" - source: hosted - version: "1.9.0" - path: - dependency: transitive - description: - name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" - url: "https://pub.dev" - source: hosted - version: "1.8.3" - pointycastle: - dependency: transitive - description: - name: pointycastle - sha256: db7306cf0249f838d1a24af52b5a5887c5bf7f31d8bb4e827d071dc0939ad346 - url: "https://pub.dev" - source: hosted - version: "3.6.2" - protobuf: - dependency: "direct main" - description: - name: protobuf - sha256: "01dd9bd0fa02548bf2ceee13545d4a0ec6046459d847b6b061d8a27237108a08" - url: "https://pub.dev" - source: hosted - version: "2.1.0" - source_span: - dependency: transitive - description: - name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 - url: "https://pub.dev" - source: hosted - version: "1.9.1" - string_scanner: - dependency: transitive - description: - name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" - source: hosted - version: "1.2.0" - term_glyph: - dependency: transitive - description: - name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" - source: hosted - version: "1.2.1" - typed_data: - dependency: transitive - description: - name: typed_data - sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" - url: "https://pub.dev" - source: hosted - version: "1.3.1" -sdks: - dart: ">=2.19.0 <4.0.0" diff --git a/dart_grpc_onhold/pubspec.yaml b/dart_grpc_onhold/pubspec.yaml deleted file mode 100644 index f06dc33d..00000000 --- a/dart_grpc_onhold/pubspec.yaml +++ /dev/null @@ -1,9 +0,0 @@ -name: helloworld - -environment: - sdk: '>=2.19.0 <3.0.0' - -dependencies: - async: ^2.10.0 - grpc: ^3.1.0 - protobuf: ^2.1.0 From affeb241af80b9d67fcd664742b698f1363dd236 Mon Sep 17 00:00:00 2001 From: Andrey Maksimov Date: Sun, 29 Oct 2023 22:20:38 +0300 Subject: [PATCH 7/9] Add http2 to dart grpc and update build.yml --- .github/workflows/build.yml | 6 +++--- dart_grpc_bench/.dockerignore | 7 ++++++- dart_grpc_bench/Dockerfile | 2 +- dart_grpc_bench/bin/server.dart | 9 +++++++-- dart_grpc_bench/pubspec.lock | 22 +++++++++++++++------- dart_grpc_bench/pubspec.yaml | 2 +- 6 files changed, 33 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 57bf6014..1dbace17 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -239,7 +239,7 @@ jobs: env: GRPC_IMAGE_NAME: ${{ needs.set-image-name.outputs.name }} - + dart_grpc_bench: runs-on: ubuntu-latest needs: @@ -248,7 +248,7 @@ jobs: if: fromJSON(needs.changed.outputs.base) || contains(needs.changed.outputs.files, 'dart_grpc_bench/') steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Build dart_grpc_bench run: ./build.sh dart_grpc_bench @@ -263,7 +263,7 @@ jobs: - if: github.ref == 'refs/heads/master' name: Log in to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} diff --git a/dart_grpc_bench/.dockerignore b/dart_grpc_bench/.dockerignore index 91da415d..d35754ed 100644 --- a/dart_grpc_bench/.dockerignore +++ b/dart_grpc_bench/.dockerignore @@ -1,3 +1,8 @@ .dockerignore Dockerfile -.dart_tool/ \ No newline at end of file +build/ +.dart_tool/ +.git/ +.github/ +.gitignore +.packages \ No newline at end of file diff --git a/dart_grpc_bench/Dockerfile b/dart_grpc_bench/Dockerfile index 8e238719..a7c325c8 100644 --- a/dart_grpc_bench/Dockerfile +++ b/dart_grpc_bench/Dockerfile @@ -1,4 +1,4 @@ -FROM dart:3.0.5-sdk AS build +FROM dart:stable AS build WORKDIR /app COPY dart_grpc_bench/pubspec.yaml /app/pubspec.yaml diff --git a/dart_grpc_bench/bin/server.dart b/dart_grpc_bench/bin/server.dart index 708a83b4..2c9b0c98 100644 --- a/dart_grpc_bench/bin/server.dart +++ b/dart_grpc_bench/bin/server.dart @@ -18,10 +18,12 @@ import 'dart:io'; import 'dart:isolate'; import 'package:grpc/grpc.dart'; +import 'package:http2/http2.dart'; import 'package:helloworld/src/generated/helloworld.pbgrpc.dart'; class GreeterService extends GreeterServiceBase { + @override Future sayHello(ServiceCall call, HelloRequest request) async { return HelloReply()..response = request.request; @@ -34,7 +36,7 @@ Future main(List args) async { if (cpus > 1) { for (var serve = 0; serve < cpus; serve++) { - Isolate.spawn(_startServer, []); + Isolate.spawn(_startServer, [cpus]); } } // Bind one server in current Isolate @@ -49,5 +51,8 @@ void _startServer([List? args]) async { services: [GreeterService()], ); await server.serve( - address: InternetAddress.anyIPv4, port: 50051, shared: true); + port: 50051, + shared: true, + http2ServerSettings: ServerSettings(concurrentStreamLimit: args?[0]) + ); } diff --git a/dart_grpc_bench/pubspec.lock b/dart_grpc_bench/pubspec.lock index 6e546b5b..f911fbd8 100644 --- a/dart_grpc_bench/pubspec.lock +++ b/dart_grpc_bench/pubspec.lock @@ -17,6 +17,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.11.0" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" collection: dependency: transitive description: @@ -61,10 +69,10 @@ packages: dependency: "direct main" description: name: grpc - sha256: "4e9bff1ebb4ff370cf471b1ab85007b408ade867dcc34b551eee7ee7da573002" + sha256: e93ee3bce45c134bf44e9728119102358c7cd69de7832d9a874e2e74eb8cab40 url: "https://pub.dev" source: hosted - version: "3.2.2" + version: "3.2.4" http: dependency: transitive description: @@ -77,10 +85,10 @@ packages: dependency: transitive description: name: http2 - sha256: "58805ebc6513eed3b98ee0a455a8357e61d187bf2e0fdc1e53120770f78de258" + sha256: "38db0c4aa9f1cd238a5d2e86aa0cc7cc91c77e0c6c94ba64bbe85e4ff732a952" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.2.0" http_parser: dependency: transitive description: @@ -125,10 +133,10 @@ packages: dependency: "direct main" description: name: protobuf - sha256: "4034a02b7e231e7e60bff30a8ac13a7347abfdac0798595fae0b90a3f0afe759" + sha256: "68645b24e0716782e58948f8467fd42a880f255096a821f9e7d0ec625b00c84d" url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "3.1.0" source_span: dependency: transitive description: @@ -162,4 +170,4 @@ packages: source: hosted version: "1.3.1" sdks: - dart: ">=3.0.5 <4.0.0" + dart: ">=3.1.0 <4.0.0" diff --git a/dart_grpc_bench/pubspec.yaml b/dart_grpc_bench/pubspec.yaml index 91c27aed..8a500ac3 100644 --- a/dart_grpc_bench/pubspec.yaml +++ b/dart_grpc_bench/pubspec.yaml @@ -1,7 +1,7 @@ name: helloworld environment: - sdk: ^3.0.5 + sdk: ^3.1.0 dependencies: async: ^2.11.0 From bf3b9de450516ecfd3fcffd5a5d8ff574d1c40b6 Mon Sep 17 00:00:00 2001 From: Hubert Date: Fri, 9 Feb 2024 14:32:00 +0100 Subject: [PATCH 8/9] Update .github/workflows/build.yml --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1dbace17..b30341b2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -239,7 +239,6 @@ jobs: env: GRPC_IMAGE_NAME: ${{ needs.set-image-name.outputs.name }} - dart_grpc_bench: runs-on: ubuntu-latest needs: From 5c9934629fd228903d20730b71084d6144ce9154 Mon Sep 17 00:00:00 2001 From: Hubert Date: Fri, 9 Feb 2024 14:33:41 +0100 Subject: [PATCH 9/9] Update .github/workflows/build.yml --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b30341b2..00b60ee4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -239,6 +239,7 @@ jobs: env: GRPC_IMAGE_NAME: ${{ needs.set-image-name.outputs.name }} + dart_grpc_bench: runs-on: ubuntu-latest needs: