From 1274d34822c03dde14a9cb47b0b40d25cb7dd1bf Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 22 Jul 2020 21:37:22 +0930 Subject: [PATCH] lightningd: add --dev-no-version-checks, use if SLOW_MACHINE and VALGRIND Reduces VALGRIND=1 node_factory.line_graph(5) time on my laptop from 42s to 36s. This is simply because forking all the subdaemons just to check the version is very expensive under valgrind. Signed-off-by: Rusty Russell --- contrib/pyln-testing/pyln/testing/utils.py | 3 +++ lightningd/lightningd.c | 10 ++++++++-- lightningd/lightningd.h | 2 ++ lightningd/options.c | 3 +++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/contrib/pyln-testing/pyln/testing/utils.py b/contrib/pyln-testing/pyln/testing/utils.py index e0e87327a..983019f13 100644 --- a/contrib/pyln-testing/pyln/testing/utils.py +++ b/contrib/pyln-testing/pyln/testing/utils.py @@ -579,6 +579,9 @@ class LightningNode(object): self.daemon.opts["dev-disconnect"] = "dev_disconnect" if DEVELOPER: self.daemon.opts["dev-fail-on-subdaemon-fail"] = None + # Don't run --version on every subdaemon if we're valgrinding and slow. + if SLOW_MACHINE and VALGRIND: + self.daemon.opts["dev-no-version-checks"] = None self.daemon.env["LIGHTNINGD_DEV_MEMLEAK"] = "1" if os.getenv("DEBUG_SUBD"): self.daemon.opts["dev-debugger"] = os.getenv("DEBUG_SUBD") diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index b44e7be30..b2f04cb38 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -139,6 +139,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx) ld->dev_force_channel_secrets_shaseed = NULL; ld->dev_force_tmp_channel_id = NULL; ld->dev_no_htlc_timeout = false; + ld->dev_no_version_checks = false; #endif /*~ These are CCAN lists: an embedded double-linked list. It's not @@ -820,8 +821,13 @@ int main(int argc, char *argv[]) * daemon running, so we call before doing almost anything else. */ pidfile_create(ld); - /*~ Make sure we can reach the subdaemons, and versions match. */ - test_subdaemons(ld); + /*~ Make sure we can reach the subdaemons, and versions match. + * This can be turned off in DEVELOPER builds with --dev-skip-version-checks, + * but the `dev_no_version_checks` field of `ld` doesn't even exist + * if DEVELOPER isn't defined, so we use IFDEV(devoption,non-devoption): + */ + if (IFDEV(!ld->dev_no_version_checks, 1)) + test_subdaemons(ld); /*~ Set up the HSM daemon, which knows our node secret key, so tells * us who we are. diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index 76d50e78e..b5d7b3698 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -240,6 +240,8 @@ struct lightningd { /* For slow tests (eg protocol tests) don't die if HTLC not * committed in 30 secs */ bool dev_no_htlc_timeout; + + bool dev_no_version_checks; #endif /* DEVELOPER */ /* tor support */ diff --git a/lightningd/options.c b/lightningd/options.c index 444670b2a..e67bc7311 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -553,6 +553,9 @@ static void dev_register_opts(struct lightningd *ld) opt_register_noarg("--dev-fail-process-onionpacket", opt_set_bool, &dev_fail_process_onionpacket, "Force all processing of onion packets to fail"); + opt_register_noarg("--dev-no-version-checks", opt_set_bool, + &ld->dev_no_version_checks, + "Skip calling subdaemons with --version on startup"); } #endif /* DEVELOPER */