Page MenuHomePhabricator

Add a utility class for getting system memory information
ClosedPublic

Authored by epriestley on Feb 23 2015, 6:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 19, 8:09 PM
Unknown Object (File)
Mon, Nov 18, 11:14 AM
Unknown Object (File)
Fri, Nov 15, 4:49 PM
Unknown Object (File)
Tue, Nov 12, 5:49 AM
Unknown Object (File)
Fri, Nov 8, 12:45 AM
Unknown Object (File)
Mon, Nov 4, 8:59 AM
Unknown Object (File)
Fri, Oct 25, 10:52 AM
Unknown Object (File)
Tue, Oct 22, 11:51 PM

Details

Summary

Ref T7352. I want to implement the hard memory barrier described in T7352#98018 to prevent all pools from scaling upward and throwing a machine into a death spiral.

To do this, I need to be able to get at least a rough picture of free system memory. This is a little murky, but we only need to have an approximate picture of it so we can cut daemons off sometime before everything goes to swap.

Add a class that queries the system and gives us some usable information back in a standard format.

Test Plan
  • Added and executed unit tests for vm_stat (os x) and /proc/meminfo (linux).
  • Ran method locally, got reasonable output.

Diff Detail

Repository
rPHU libphutil
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

epriestley retitled this revision from to Add a utility class for getting system memory information.
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added a reviewer: btrahan.
btrahan edited edge metadata.

On this memory detection stuff, if certain OS flavors are particularly bad, maybe we should not allow for autoscaling on those flavors? Not even sure how murky things can get, but I would want to avoid users having problems with this feature, especially since I think the autoscaling thing isn't useful for smaller (most) installations. Just waxing here I guess...

This revision is now accepted and ready to land.Feb 23 2015, 6:14 PM

Yeah, current state of the world is:

  • It's OK if we underreport free space, since it will just mean the daemons never autoscale up (or don't scale up as much), which is fine.
  • On OSX, we may underreport free space relative to Linux, I think (?). Specifically, I don't have a way to identify and subtract disk cache like we can on Linux.

So, right now, this really just means that OSX may not scale up as much as Linux would, but that should be fine. No one (almost no one?) is running a production server on OSX anyway, and they could theoretically set the memory reserve to 0 if they were and really wanted aggressive autoscaling.

I didn't want to put a ton of daemon-specific details in the comments here so I left it sort of vague, but we only get into trouble if some system dramatically overreports free space.

I'm also probably just going to try/catch this test in the daemons (so we don't break on, say, FreeBSD) and default the reserved memory to 0 (so normal installs don't do this check anyway), since this concern is only a problem on instanced clusters.

This revision was automatically updated to reflect the committed changes.

/proc/meminfo is not cgroup aware so from LXC/Docker/whatever you will see the free memory of the physical host, not your little container.

I think that just means we loose the fancy back pressure this implements, but in normal operations nothing terrible will happen.