From ccd4d46391c75a94337c5a22a4848e28d516fa06 Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Fri, 28 Oct 2022 10:47:47 +0200 Subject: [PATCH 1/6] Do not use optimised debug builds Optimised debug builds result in an extremely slow code-build-test cycle. The reason we do this is because we have a few tests which end up overflowing the stack. This increases the stack instead. --- .cargo/config.toml | 9 +++++++++ Cargo.toml | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 000000000..34c30d13f --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,9 @@ +[env] +# In unoptimised builds tokio tends to use a lot of stack space when +# creating some complicated futures. Some of our tests manage to not +# fit in the default 2MiB stack anymore due to this. Because +# compiling optimised builds takes a very long time we prefer to avoid +# that. Setting this environment variable ensures that when invoking +# `cargo test` threads are allowed to have a large enough stack size +# without needing to use an optimised build. +RUST_MIN_STACK = "8388608" diff --git a/Cargo.toml b/Cargo.toml index 871ad9dbb..82aa15e55 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ rust-version = "1.56" [profile.dev] debug = 0 panic = 'abort' -opt-level = 1 +opt-level = 0 [profile.release] lto = true From 056b8ba1e84981254b6e0571015043f3f6619ad6 Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Fri, 28 Oct 2022 11:07:25 +0200 Subject: [PATCH 2/6] link tokio issue, remove opt-level line opt-level relies on the default instead --- .cargo/config.toml | 14 ++++++++------ Cargo.toml | 1 - 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 34c30d13f..e2e5fa90e 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,9 +1,11 @@ [env] # In unoptimised builds tokio tends to use a lot of stack space when -# creating some complicated futures. Some of our tests manage to not -# fit in the default 2MiB stack anymore due to this. Because -# compiling optimised builds takes a very long time we prefer to avoid -# that. Setting this environment variable ensures that when invoking -# `cargo test` threads are allowed to have a large enough stack size -# without needing to use an optimised build. +# creating some complicated futures, tokio has an open issue for this: +# https://github.com/tokio-rs/tokio/issues/2055. Some of our tests +# manage to not fit in the default 2MiB stack anymore due to this, so +# while the issue is not resolved we want to work around this. +# Because compiling optimised builds takes a very long time we prefer +# to avoid that. Setting this environment variable ensures that when +# invoking `cargo test` threads are allowed to have a large enough +# stack size without needing to use an optimised build. RUST_MIN_STACK = "8388608" diff --git a/Cargo.toml b/Cargo.toml index 82aa15e55..049c1225e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,6 @@ rust-version = "1.56" [profile.dev] debug = 0 panic = 'abort' -opt-level = 0 [profile.release] lto = true From 38efde6c98aa1097e9cb38510b9c0100a5267aa5 Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Fri, 28 Oct 2022 11:22:16 +0200 Subject: [PATCH 3/6] Seems the npm stuff manages to avoid the cargo config file --- .github/workflows/jsonrpc.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/jsonrpc.yml b/.github/workflows/jsonrpc.yml index 082ddb569..5b1781a46 100644 --- a/.github/workflows/jsonrpc.yml +++ b/.github/workflows/jsonrpc.yml @@ -8,6 +8,7 @@ on: env: CARGO_TERM_COLOR: always + RUST_MIN_STACK: "8388608" jobs: build_and_test: From 772514940cf8ab7c7fe142615495da45b000dc57 Mon Sep 17 00:00:00 2001 From: link2xt Date: Tue, 1 Nov 2022 23:05:38 +0000 Subject: [PATCH 4/6] Set RUST_MIN_STACK in JSON-RPC tests --- deltachat-jsonrpc/typescript/test/test_base.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deltachat-jsonrpc/typescript/test/test_base.ts b/deltachat-jsonrpc/typescript/test/test_base.ts index 71c79b235..3d6da6faa 100644 --- a/deltachat-jsonrpc/typescript/test/test_base.ts +++ b/deltachat-jsonrpc/typescript/test/test_base.ts @@ -30,7 +30,8 @@ export async function startServer(port: number = RPC_SERVER_PORT): Promise Date: Thu, 3 Nov 2022 20:02:07 +0000 Subject: [PATCH 5/6] Set RUST_MIN_STACK for Python tests --- python/tox.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/tox.ini b/python/tox.ini index 74cc1c554..eaa444646 100644 --- a/python/tox.ini +++ b/python/tox.ini @@ -10,6 +10,9 @@ envlist = commands = pytest -n6 --extra-info --reruns 2 --reruns-delay 5 -v -rsXx --ignored --strict-tls {posargs: tests examples} pip wheel . -w {toxworkdir}/wheelhouse --no-deps +setenv = +# Avoid stack overflow when Rust core is built without optimizations. + RUST_MIN_STACK=8388608 passenv = DCC_RS_DEV DCC_RS_TARGET From 146478e450766c74aae20991e5874f57d2e7e5d3 Mon Sep 17 00:00:00 2001 From: link2xt Date: Fri, 4 Nov 2022 12:33:08 +0000 Subject: [PATCH 6/6] Optimize debug builds, but not tests --- Cargo.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 049c1225e..dd7f55fbe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,10 @@ rust-version = "1.56" [profile.dev] debug = 0 panic = 'abort' +opt-level = 1 + +[profile.test] +opt-level = 0 [profile.release] lto = true