mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-19 05:44:12 +01:00
pytest: don't checksum plugins on startup in VALGRIND developer mode.
This loads up 20MB of plugins temporarily; we seem to be getting OOM killed under CI and I wonder if this is contributing. Doesn't significantly reduce runtime here, but I have lots of memory. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
09bbda4bca
commit
65bb989cf1
@ -675,6 +675,7 @@ class LightningNode(object):
|
||||
self.daemon.opts["dev-debugger"] = os.getenv("DEBUG_SUBD")
|
||||
if valgrind:
|
||||
self.daemon.env["LIGHTNINGD_DEV_NO_BACKTRACE"] = "1"
|
||||
self.daemon.opts["dev-no-plugin-checksum"] = None
|
||||
else:
|
||||
# Under valgrind, scanning can access uninitialized mem.
|
||||
self.daemon.env["LIGHTNINGD_DEV_MEMLEAK"] = "1"
|
||||
|
@ -114,6 +114,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
|
||||
* same exact code users will be running. */
|
||||
#if DEVELOPER
|
||||
ld->dev_debug_subprocess = NULL;
|
||||
ld->dev_no_plugin_checksum = false;
|
||||
ld->dev_disconnect_fd = -1;
|
||||
ld->dev_subdaemon_fail = false;
|
||||
ld->dev_allow_localhost = false;
|
||||
|
@ -207,6 +207,9 @@ struct lightningd {
|
||||
/* If we want to debug a subdaemon/plugin. */
|
||||
const char *dev_debug_subprocess;
|
||||
|
||||
/* If we have --dev-no-plugin-checksum */
|
||||
bool dev_no_plugin_checksum;
|
||||
|
||||
/* If we have a --dev-disconnect file */
|
||||
int dev_disconnect_fd;
|
||||
|
||||
|
@ -584,6 +584,10 @@ static void dev_register_opts(struct lightningd *ld)
|
||||
opt_register_early_arg("--dev-debugger=<subprocess>", opt_subprocess_debug, NULL,
|
||||
ld, "Invoke gdb at start of <subprocess>");
|
||||
|
||||
opt_register_early_noarg("--dev-no-plugin-checksum", opt_set_bool,
|
||||
&ld->dev_no_plugin_checksum,
|
||||
"Don't checksum plugins to detect changes");
|
||||
|
||||
opt_register_noarg("--dev-no-reconnect", opt_set_invbool,
|
||||
&ld->reconnect,
|
||||
"Disable automatic reconnect-attempts by this node, but accept incoming");
|
||||
|
@ -209,9 +209,14 @@ static void destroy_plugin(struct plugin *p)
|
||||
}
|
||||
}
|
||||
|
||||
static u32 file_checksum(const char* path)
|
||||
static u32 file_checksum(struct lightningd *ld, const char *path)
|
||||
{
|
||||
char *content = grab_file(tmpctx, path);
|
||||
char *content;
|
||||
|
||||
if (IFDEV(ld->dev_no_plugin_checksum, false))
|
||||
return 0;
|
||||
|
||||
content = grab_file(tmpctx, path);
|
||||
if (content == NULL) return 0;
|
||||
return crc32c(0, content, tal_count(content));
|
||||
}
|
||||
@ -231,7 +236,7 @@ struct plugin *plugin_register(struct plugins *plugins, const char* path TAKES,
|
||||
if (important)
|
||||
p_temp->important = true;
|
||||
/* stop and restart plugin on different checksum */
|
||||
chksum = file_checksum(path);
|
||||
chksum = file_checksum(plugins->ld, path);
|
||||
if (p_temp->checksum != chksum && !p_temp->important) {
|
||||
plugin_kill(p_temp, LOG_INFORM,
|
||||
"Plugin changed, needs restart.");
|
||||
@ -246,7 +251,7 @@ struct plugin *plugin_register(struct plugins *plugins, const char* path TAKES,
|
||||
p = tal(plugins, struct plugin);
|
||||
p->plugins = plugins;
|
||||
p->cmd = tal_strdup(p, path);
|
||||
p->checksum = file_checksum(p->cmd);
|
||||
p->checksum = file_checksum(plugins->ld, p->cmd);
|
||||
p->shortname = path_basename(p, p->cmd);
|
||||
p->start_cmd = start_cmd;
|
||||
|
||||
|
@ -2520,6 +2520,9 @@ plugin.run()
|
||||
|
||||
# get a node that is not started so we can put a plugin in its lightning_dir
|
||||
n = node_factory.get_node(start=False)
|
||||
if "dev-no-plugin-checksum" in n.daemon.opts:
|
||||
del n.daemon.opts["dev-no-plugin-checksum"]
|
||||
|
||||
lndir = n.daemon.lightning_dir
|
||||
|
||||
# write hello world plugin to lndir/plugins
|
||||
|
Loading…
Reference in New Issue
Block a user