Skip to content

Commit

Permalink
fix: -M -> -R, support memory_limit_multiplier (#6)
Browse files Browse the repository at this point in the history
Change memory submission from -M to -R. Add support for configuration option memory_limit_multiplier to set a memory limit. memory_limit_multiplier = 1 will reproduce the prior behavior. Addresses #4.
  • Loading branch information
adthrasher authored Feb 7, 2024
1 parent 3528ccc commit eecd33f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ Changelog
.. This document is user facing. Please word the changes in such a way
.. that users understand how the changes affect the new version.
version 0.1.2
----------------------------
+ Update memory reservation to use "-R rusage[mem=...]" instead of "-M".
To use "-M", set "memory_limit_multiplier" in configuration to a
positive value.
+ Support config option "memory_limit_multiplier" to set a hard limit
on memory usage.

version 0.1.1
----------------------------
+ Update log location on retry
+ Correct memory calculation

version 0.1.0
----------------------------
Initial release with the following features:
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ example can be used to use miniwdl on a LSF cluster:
}
command_shell = /bin/bash
memory_limit_multiplier = 1.0
[singularity]
# This plugin wraps the singularity backend. Make sure the settings are
Expand All @@ -70,4 +72,4 @@ example can be used to use miniwdl on a LSF cluster:
extra_args=""
# Task memory specifications should be interpreted as per-job not per-core (LSF default)
memory_per_job = true
```
```
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "miniwdl-lsf"
version = "0.1.1"
version = "0.1.2"
description = "miniwdl lsf backend using singularity"
authors = ["Andrew Thrasher <adthrasher@gmail.com>"]
license = "MIT"
Expand Down
13 changes: 11 additions & 2 deletions src/miniwdl_lsf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,18 @@ def _lsf_invocation(self):
memory_divisor = 1
if self.cfg["lsf"].get_bool("memory_per_job") and cpu is not None:
memory_divisor = cpu

# Round to the nearest megabyte and divide by the memory divisor.
memory_request = round((memory / (1000 ** 2)) / memory_divisor)

# Round to the nearest megabyte.
bsub_args.extend(["-M", f"{round((memory / (1000 ** 2)) / memory_divisor)}M"])
# Handle memory limit multiplier.
memory_limit_multiplier = self.cfg["task_runtime"].get_float("memory_limit_multiplier")
if memory_limit_multiplier > 0.0:
memory_limit = round(memory_request * memory_limit_multiplier)
bsub_args.extend(["-M", f"{memory_limit}M"])

# Set memory request.
bsub_args.extend(["-R", f"rusage[mem={memory_request}M]"])

if self.cfg.has_section("lsf"):
extra_args = self.cfg.get("lsf", "extra_args")
Expand Down

0 comments on commit eecd33f

Please sign in to comment.