@@ -115,7 +115,7 @@ def get_deterministic_priv_key(self):
115115 ]
116116 return PRIV_KEYS [self .index ]
117117
118- def get_mem_rss (self ):
118+ def get_mem_rss_kilobytes (self ):
119119 """Get the memory usage (RSS) per `ps`.
120120
121121 Returns None if `ps` is unavailable.
@@ -291,26 +291,30 @@ def assert_debug_log(self, expected_msgs):
291291 self ._raise_assertion_error ('Expected message "{}" does not partially match log:\n \n {}\n \n ' .format (expected_msg , print_log ))
292292
293293 @contextlib .contextmanager
294- def assert_memory_usage_stable (self , perc_increase_allowed = 0.03 ):
294+ def assert_memory_usage_stable (self , * , increase_allowed = 0.03 ):
295295 """Context manager that allows the user to assert that a node's memory usage (RSS)
296296 hasn't increased beyond some threshold percentage.
297+
298+ Args:
299+ increase_allowed (float): the fractional increase in memory allowed until failure;
300+ e.g. `0.12` for up to 12% increase allowed.
297301 """
298- before_memory_usage = self .get_mem_rss ()
302+ before_memory_usage = self .get_mem_rss_kilobytes ()
299303
300304 yield
301305
302- after_memory_usage = self .get_mem_rss ()
306+ after_memory_usage = self .get_mem_rss_kilobytes ()
303307
304308 if not (before_memory_usage and after_memory_usage ):
305309 self .log .warning ("Unable to detect memory usage (RSS) - skipping memory check." )
306310 return
307311
308312 perc_increase_memory_usage = (after_memory_usage / before_memory_usage ) - 1
309313
310- if perc_increase_memory_usage > perc_increase_allowed :
314+ if perc_increase_memory_usage > increase_allowed :
311315 self ._raise_assertion_error (
312316 "Memory usage increased over threshold of {:.3f}% from {} to {} ({:.3f}%)" .format (
313- perc_increase_allowed * 100 , before_memory_usage , after_memory_usage ,
317+ increase_allowed * 100 , before_memory_usage , after_memory_usage ,
314318 perc_increase_memory_usage * 100 ))
315319
316320 def assert_start_raises_init_error (self , extra_args = None , expected_msg = None , match = ErrorMatch .FULL_TEXT , * args , ** kwargs ):
0 commit comments