Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use RTS --disable-delayed-os-memory-return by default for the node #2493

Merged
merged 3 commits into from
Mar 17, 2021

Conversation

dcoutts
Copy link
Contributor

@dcoutts dcoutts commented Mar 16, 2021

By default on Linux the RTS uses a fast method of returning memory to
the kernel. This fast method allows the kernel to free the memory
lazily when there is memory pressure. The downside of leting the kernel
do it lazily is that the RSS measure is also only updated lazily.

This has the effect of scaring system admins that the RSS is really
high, when in reality that does not reflect the actual amount of memory
being used.

So by using +RTS --disable-delayed-os-memory-return we ask the RTS to
not use the faster freeing method and use the normal method that updates
the RSS eagerly.

By default on Linux the RTS uses a fast method of returning memory to
the kernel. This fast method allows the kernel to free the memory
lazily when there is memory pressure. The downside of leting the kernel
do it lazily is that the RSS measure is also only updated lazily.

This has the effect of scaring system admins that the RSS is really
high, when in reality that does not reflect the actual amount of memory
being used.

So by using +RTS --disable-delayed-os-memory-return we ask the RTS to
not use the faster freeing method and use the normal method that updates
the RSS eagerly.
@nc6
Copy link
Contributor

nc6 commented Mar 16, 2021

bors merge

iohk-bors bot added a commit that referenced this pull request Mar 16, 2021
2493: Use RTS --disable-delayed-os-memory-return by default for the node r=nc6 a=dcoutts

By default on Linux the RTS uses a fast method of returning memory to
the kernel. This fast method allows the kernel to free the memory
lazily when there is memory pressure. The downside of leting the kernel
do it lazily is that the RSS measure is also only updated lazily.

This has the effect of scaring system admins that the RSS is really
high, when in reality that does not reflect the actual amount of memory
being used.

So by using +RTS --disable-delayed-os-memory-return we ask the RTS to
not use the faster freeing method and use the normal method that updates
the RSS eagerly.

Co-authored-by: Duncan Coutts <duncan@well-typed.com>
@newhoggy
Copy link
Contributor

newhoggy commented Mar 16, 2021

For some reason this is failing on ghc-8.6.5.

I pushed a commit to limit the use of this RTS option to ghc-8.10.x and above. Maybe that will help.

@nc6
Copy link
Contributor

nc6 commented Mar 16, 2021

@newhoggy Can you approve? Seems like it needs a codeowner

else
ghc-options: "-with-rtsopts=-T -I0 -N2 -A16m --disable-delayed-os-memory-return"

if impl(ghc >= 8.10)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

But look at what that does. This mean we use no args at all for earlier ghc versions.

I think it might actually work to use multiple -with-rtsopts like:

ghc-options:          "-with-rtsopts=-T -I0 -N1 -A16m"
if arch(arm)
  ghc-options:        "-with-rtsopts=-N1"
else
  ghc-options:        "-with-rtsopts=-N2"
if impl(ghc >= 8.10)
  ghc-options:        "-with-rtsopts=--disable-delayed-os-memory-return"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW, no need to test this in CI, check in any local "hello world" local Haskell program that it works to use multiple -with-rtsopts= and that they get combined.

Copy link
Contributor

Choose a reason for hiding this comment

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

Updated. Thanks!

@newhoggy newhoggy force-pushed the dcoutts/disable-delayed-os-memory-return branch from 5d7922d to ac5527e Compare March 16, 2021 14:25
iohk-bors bot added a commit that referenced this pull request Mar 16, 2021
2495: nixos: add sensible rtsArgs defaults r=disassembler a=jbgi

that include --disable-delayed-os-memory-return

nixos followup to #2493

Co-authored-by: Jean-Baptiste Giraudeau <jean-baptiste.giraudeau@iohk.io>
@nc6
Copy link
Contributor

nc6 commented Mar 17, 2021

bors merge

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Mar 17, 2021

@iohk-bors iohk-bors bot merged commit f7f310c into master Mar 17, 2021
@iohk-bors iohk-bors bot deleted the dcoutts/disable-delayed-os-memory-return branch March 17, 2021 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants