Skip to content

Set $GALAXY_MEMORY_GB and allow for lowering values by an overhead.#21735

Open
natefoo wants to merge 2 commits intogalaxyproject:devfrom
natefoo:galaxy-memory-gb
Open

Set $GALAXY_MEMORY_GB and allow for lowering values by an overhead.#21735
natefoo wants to merge 2 commits intogalaxyproject:devfrom
natefoo:galaxy-memory-gb

Conversation

@natefoo
Copy link
Copy Markdown
Member

@natefoo natefoo commented Feb 3, 2026

Fixes #15952.

How to test the changes?

(Select all options that apply)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.
  • Instructions for manual testing are as follows:
    1. Using Slurm you can verify that $GALAXY_MEMORY_GB is set properly using metrics or inspecting the tool_script.sh
    2. Using the local runner you can set $GALAXY_MEMORY_MB as an env var and the others should be set accordingly.
    3. Test the overhead and floor vars the same way, this simple tool is helpful:
      <tool id="vartest" name="vartest" version="0.0.1" profile="16.04">
          <command><![CDATA[
              echo "$echo" >  "$output1"
              ; declare -p GALAXY_MEMORY_MB >> "$output1" 2>&1 || true
              ; declare -p GALAXY_MEMORY_MB_PER_SLOT >> "$output1" 2>&1 || true
              ; declare -p GALAXY_MEMORY_GB >> "$output1" 2>&1 || true
              ; declare -p GALAXY_MEMORY_GB_PER_SLOT >> "$output1" 2>&1 || true
              ; declare -p GALAXY_MEMORY_MB_OVERHEAD >> "$output1" 2>&1 || true
              ; declare -p GALAXY_MEMORY_MB_FLOOR >> "$output1" 2>&1 || true
          ]]></command>
          <inputs>
              <param name="echo" type="text" title="Text to echo"/>
          </inputs>
          <outputs>
              <data name="output1" format="txt" />
          </outputs>
      </tool>

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

@github-actions github-actions bot added this to the 26.1 milestone Feb 3, 2026
Copy link
Copy Markdown
Contributor

@bernt-matthias bernt-matthias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if am additive or multiplicative overhead is better (or both). In my setup I use -Xmx$JAVAMEM where $GALAXY_MEMORY_MB*2/3 seemed to be a value that always works for me, but I never tested with additive overheads.

fi

if [ -n "$GALAXY_MEMORY_MB" -a -n "${GALAXY_MEMORY_MB_OVERHEAD:-}" ]; then
GALAXY_MEMORY_MB=$(($GALAXY_MEMORY_MB - GALAXY_MEMORY_MB_OVERHEAD))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only work for SLURM jobs (for which we only set GALAXY_MEMORY_MB so far) for SGE jobs we only have GALAXY_MEMORY_MB_PER_SLOT.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll reorder - I originally had it below the next bit where we set $GALAXY_MEMORY_MB from $GALAXY_MEMORY_MB_PER_SLOT, but moved it up so $GALAXY_MEMORY_MB_PER_SLOT would take the overhead into account. I can move it back down and then just recalculate $GALAXY_MEMORY_MB_PER_SLOT accordingly.

fi
if [ -n "$GALAXY_MEMORY_GB" -a -z "$GALAXY_MEMORY_GB_PER_SLOT" ]; then
GALAXY_MEMORY_GB_PER_SLOT=$(($GALAXY_MEMORY_GB / $GALAXY_SLOTS))
[ "$GALAXY_MEMORY_GB_PER_SLOT" -gt 0 ] || GALAXY_MEMORY_GB_PER_SLOT=1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For GALAXY_SLOTS>1 this would mean that the total memory is larger then the floor value? Why are you checking for greater 0 anyway (Also in the previous if) -- is it for accomodating rounding problems?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the idea here is if $(($GALAXY_MEMORY_GB / $GALAXY_SLOTS)) is less than 1, the division results in 0, so this ensures $GALAXY_MEMORY_GB_PER_SLOT is not set to 0, since I imagine most tools are not going to react well to that. I admit that setting it to 1 is also wrong, but I don't have a better solution for this case.

@natefoo
Copy link
Copy Markdown
Member Author

natefoo commented Feb 5, 2026

So I did think about additive vs. multiplicative beforehand and the issue I saw with that is that at large memory allocations you waste a lot of memory with multiplicative. I think it's more often the case that you want to leave 1-2 GB overhead than you want to leave 25%, especially when you're giving a job 1 TB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set $GALAXY_MEMORY_GB

2 participants