From 7807d2177e54f108f170b6b495a82397e563fe01 Mon Sep 17 00:00:00 2001 From: Geod24 Date: Thu, 23 Jul 2020 09:52:42 +0900 Subject: [PATCH 1/3] Move types that don't depend on template args our of spawn This was reported by the LDC developers as being the source of an ICE we are seeing on Windows. --- source/geod24/LocalRest.d | 95 ++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 42 deletions(-) diff --git a/source/geod24/LocalRest.d b/source/geod24/LocalRest.d index 78290848..96890ca2 100644 --- a/source/geod24/LocalRest.d +++ b/source/geod24/LocalRest.d @@ -103,6 +103,7 @@ module geod24.LocalRest; static import C = geod24.concurrency; import geod24.Serialization; +import std.datetime.systime : Clock, SysTime; import std.format; import std.meta : AliasSeq; import std.traits : fullyQualifiedName, Parameters, ReturnType; @@ -203,6 +204,58 @@ public class ClientException : Exception } } +/// Simple exception unwind the stack when we need to terminate/restart, +/// used by `spawn` but kept here as it doesn't depend on template parameters. +private final class ExitException : Exception +{ + public bool restart; + + this () @safe pure nothrow @nogc + { + super("You should never see this exception - please report a bug"); + } +} + +/// Wrapper for data inside of `spawn`, kept here as it doesn't +/// depend on template parameters +private struct Variant +{ + pure nothrow @nogc: + + public this (Response res) @trusted + { + this.res = res; + this.tag = 0; + } + public this (Command cmd) @trusted + { + this.cmd = cmd; + this.tag = 1; + } + + union + { + Response res; + Command cmd; + } + + public ubyte tag; +} + +/// Used by `spawn` for recording current filtering / sleeping setting +private struct Control +{ + public FilterAPI filter; // filter specific messages + public SysTime sleep_until; // sleep until this time + public bool drop; // drop messages if sleeping + + public bool isSleeping() const @safe /* nothrow: Not on Windows (currTime) */ + { + return this.sleep_until != SysTime.init + && Clock.currTime < this.sleep_until; + } +} + /// Simple wrapper to deal with tuples /// Vibe.d might emit a pragma(msg) when T.length == 0 private struct ArgWrapper (T...) @@ -536,51 +589,9 @@ public final class RemoteAPI (API, alias S = VibeJSONSerializer!()) : API C.Tid self, string file, int line, CtorParams!Implementation cargs) nothrow { - import std.datetime.systime : Clock, SysTime; import std.algorithm : each; import std.range; - /// Simple exception unwind the stack when we need to terminate/restart - static final class ExitException : Exception - { - bool restart; - - this () @safe pure nothrow @nogc - { - super("You should never see this exception - please report a bug"); - } - } - - // very simple & limited variant, to keep it performant. - // should be replaced by a real Variant later - static struct Variant - { - this (Response res) { this.res = res; this.tag = 0; } - this (Command cmd) { this.cmd = cmd; this.tag = 1; } - - union - { - Response res; - Command cmd; - } - - ubyte tag; - } - - // used for controling filtering / sleep - static struct Control - { - FilterAPI filter; // filter specific messages - SysTime sleep_until; // sleep until this time - bool drop; // drop messages if sleeping - - bool isSleeping() const - { - return this.sleep_until != SysTime.init - && Clock.currTime < this.sleep_until; - } - } - scope exc = new ExitException(); void runNode () From d2744d12bf0948b3c3515db6d70bcfbea181828a Mon Sep 17 00:00:00 2001 From: Geod24 Date: Thu, 23 Jul 2020 10:54:22 +0900 Subject: [PATCH 2/3] Windows: Reduce number of spawned / waiting Fibers when simulating outage --- source/geod24/LocalRest.d | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/geod24/LocalRest.d b/source/geod24/LocalRest.d index 96890ca2..452e70d5 100644 --- a/source/geod24/LocalRest.d +++ b/source/geod24/LocalRest.d @@ -1439,7 +1439,10 @@ unittest // Now drop many messages n1.sleep(1.seconds, true); - for (size_t i = 0; i < 500; i++) + // Github Action runs out of memory with MessageCount == 500 + version (Windows) enum MessageCount = 100; + else enum MessageCount = 500; + for (size_t i = 0; i < MessageCount; i++) n2.asyncCall(); // Make sure we don't end up blocked forever n1.sleep(0.seconds, false); From 1317e7da002efa4db33735af83486b5663f50388 Mon Sep 17 00:00:00 2001 From: Geod24 Date: Tue, 21 Jul 2020 10:25:31 +0900 Subject: [PATCH 3/3] Replace Travis CI with Github Actions, raise minimum version Using Github Actions allows us to have testing on all three platforms. Additionally, the minimum version have been raised. Versions lower than 2.088.1 / LDC 1.17.0 do not work on Mac OSX 10.15 (Catalina) because of the removal of a private API Druntime was using. Additionally, we caught a few regressions which were only recently fixed. --- .github/workflows/main.yaml | 40 +++++++++++++++++++++++++++++++++++++ .travis.yml | 37 ---------------------------------- 2 files changed, 40 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/main.yaml delete mode 100644 .travis.yml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 00000000..bc9eee95 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,40 @@ +# Github action to test localrest +# +# Also upload the documentation to Github pages +# +name: CI + +on: [push, pull_request] + +jobs: + main: + name: Run + # Matrix configuration + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, macOS-latest, windows-latest ] + dc: [ ldc-master, dmd-master, ldc-latest, dmd-latest, ldc-1.20.0, dmd-2.090.1 ] + + runs-on: ${{ matrix.os }} + timeout-minutes: 15 + + # The actual work being performed + steps: + - uses: actions/checkout@v2 + + - name: Prepare compiler + uses: dlang-community/setup-dlang@v1 + with: + compiler: ${{ matrix.dc }} + + - name: Test + shell: bash + run: dub test -b unittest-cov --compiler=${DC} + + - uses: codecov/codecov-action@v1 + with: + name: localrest-${{ matrix.os }}-${{ matrix.dc }} + flags: unittest + # false until we can re-trigger a single test in Github + fail_ci_if_error: false diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 75f32cc9..00000000 --- a/.travis.yml +++ /dev/null @@ -1,37 +0,0 @@ -language: d - -# Trusty is Travis' default but reached EOL 2019-04-30 -dist: xenial - -branches: - only: - - /^v\d+\.(x|[\d]+)\.(x|[\d]+)([-|\+](\S+))?$/ - -os: - - linux - - osx - -d: - - dmd - - ldc - - dmd-2.085.1 - - ldc-1.14.0 - -# Latest version of DMD/GDC/LDC -matrix: - include: - - os: linux - addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - gdc-9 - env: DC=gdc - -# TODO: Make `vibe-d:data` optional, and fetch it here for testing -# Currently dub complains even after running `dub fetch vibe-d:data`. -script: - - dub test -b unittest-cov --compiler=${DC} -after_success: - - bash <(curl -s https://codecov.io/bash) -cF unittests