Skip to content

Commit

Permalink
pytest: don't valgrind plugins under CI if many nodes.
Browse files Browse the repository at this point in the history
Just pick one at random to trace fully.

Eg. test_gossip.py::test_getroute_exclude (creates 5 nodes)

Before:
	%MEM VSZ      RSS
	27.6 15941008 5106764

After:
	%MEM VSZ      RSS
	15.6 12234844 3009016

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and ZmnSCPxj committed Nov 27, 2021
1 parent 7a6fd70 commit e6ba660
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions contrib/pyln-testing/pyln/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ def __init__(self, node_id, lightning_dir, bitcoind, executor, valgrind, may_fai
allow_bad_gossip=False,
db=None, port=None, disconnect=None, random_hsm=None, options=None,
jsonschemas={},
valgrind_plugins=True,
**kwargs):
self.bitcoin = bitcoind
self.executor = executor
Expand Down Expand Up @@ -690,11 +691,14 @@ def __init__(self, node_id, lightning_dir, bitcoind, executor, valgrind, may_fai
if dsn is not None:
self.daemon.opts['wallet'] = dsn
if valgrind:
trace_skip_pattern = '*python*,*bitcoin-cli*,*elements-cli*'
if not valgrind_plugins:
trace_skip_pattern += ',*plugins*'
self.daemon.cmd_prefix = [
'valgrind',
'-q',
'--trace-children=yes',
'--trace-children-skip=*python*,*bitcoin-cli*,*elements-cli*',
'--trace-children-skip={}'.format(trace_skip_pattern),
'--error-exitcode=7',
'--log-file={}/valgrind-errors.%p'.format(self.daemon.lightning_dir)
]
Expand Down Expand Up @@ -1280,12 +1284,20 @@ def get_nodes(self, num_nodes, opts=None):

assert len(opts) == num_nodes

# Only trace one random node's plugins, to avoid OOM.
if SLOW_MACHINE:
valgrind_plugins = [False] * num_nodes
valgrind_plugins[random.randint(0, num_nodes - 1)] = True
else:
valgrind_plugins = [True] * num_nodes

jobs = []
for i in range(num_nodes):
node_opts, cli_opts = self.split_options(opts[i])
jobs.append(self.executor.submit(
self.get_node, options=cli_opts,
node_id=self.get_node_id(), **node_opts
node_id=self.get_node_id(), **node_opts,
valgrind_plugins=valgrind_plugins[i]
))

return [j.result() for j in jobs]
Expand Down

0 comments on commit e6ba660

Please sign in to comment.