gperftools / gperftools/gperftools

ReleaseFreeMemory holds page heap lock for a long time

Open
#754 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

alk-wants-this-soon
Dominant language
C++
Stars
9k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

I'm working on an application which accumulates large heaps (100GB+) and then deallocates nearly the entire heap almost instantly. We call ReleaseFreeMemory() to drop the RSS down to a small value, but found that it can sometimes hold the page heap mutex for 10+ seconds, causing unacceptable latencies, timeouts, etc.

Most likely the slowness comes from the actual madvise() calls, rather than from finding the spans to release. It would be great if there were a way to move these madvise() calls outside of the lock -- for example, by moving the spans to the RETURNED_FREELIST before calling madvise, and madvising after releasing the lock. Of course, things get tricky with memory accounting and ensuring that the spans aren't later re-used, but curious if anyone has prototyped anything like this.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at ReleaseFreeMemory and trace the page heap mutex, span selection, and madvise calls. Investigate whether spans can be safely moved to the RETURNED_FREELIST before madvise without breaking memory accounting or allowing reuse. Done means reducing lock-held latency while preserving correct span ownership and RSS release.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.