Opened 3 years ago

Closed 3 years ago

#13288 closed bug (fixed)

Resident set size exceeds +RTS -M limit with large nurseries

Reported by: j6carey Owned by:
Priority: normal Milestone: 8.2.1
Component: Runtime System Version: 8.0.2
Keywords: Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Runtime performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D3143
Wiki Page:

Description (last modified by j6carey)

We observed high resident set size well in excess of the +RTS -M limit in a long-running, high data-volume Haskell application that Awake Networks is deploying on a network appliance.

We think that the current GC.c code has two bugs that, at least in combination with each other, become significant when high +RTS -N and very high +RTS -A values are used.

  1. As we approach the -M limit, the computation of the new size for generation 1 appears to be based on an incorrect figure for the total size of the nursery. The -A value is used instead of the product of that value with -N. This problem could lead to the total heap size exceeding the -M limit.
  1. Memory allocated from the operating system is freed only if the RTS thinks that it would not be reallocated soon. The estimate for what will be needed soon is based on fewer inputs than the actual resizing logic, and in particular it is not affected by -M. Thus it might keep free mblocks in excess of the -M limit, based on an expected heap growth that would be forbidden by -M.

We prepared a fix to address these issues; it points out the particular lines of code: https://phabricator.haskell.org/D3143

Change History (6)

comment:1 Changed 3 years ago by j6carey

Description: modified (diff)

comment:2 Changed 3 years ago by j6carey

Description: modified (diff)

comment:3 Changed 3 years ago by bgamari

Differential Rev(s): Phab:D3143
Milestone: 8.2.1
Status: newpatch

comment:4 Changed 3 years ago by Ben Gamari <ben@…>

In 7d116e55/ghc:

rts: Correct the nursery size in the gen 1 growth computation

Fixes trac issue #13288.

Reviewers: austin, bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: mutjida, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3143

comment:5 Changed 3 years ago by j6carey

Thank you for committing this fix.

We still see RSS growth beyond the -M limit, but that is due to having a large number of partially-used megablocks involved in the free block group list. They cannot be returned to the operating system because they are still partly in use, and yet their free space is not counted as heap size, and therefore is not limited by -M. We have not yet figured out why there is such high fragmentation in our application. But clearly that is a distinct issue.

comment:6 Changed 3 years ago by bgamari

Resolution: fixed
Status: patchclosed

Alright, I will close this in that case.

Note: See TracTickets for help on using tickets.