Browse Source

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 <rusty@rustcorp.com.au>
fixup-0.9.0
Rusty Russell 4 years ago
committed by Christian Decker
parent
commit
1274d34822
  1. 3
      contrib/pyln-testing/pyln/testing/utils.py
  2. 10
      lightningd/lightningd.c
  3. 2
      lightningd/lightningd.h
  4. 3
      lightningd/options.c

3
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")

10
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.

2
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 */

3
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 */

Loading…
Cancel
Save