News for hackers. Stuff that matters.
Re:Linux memory manager and your big data by EvanMiller on Wednesday November 27, 2013 @02:30PM (#6810495)
A "50/50" rule such as the one described is a clear signal that the memory manager's cache eviction policy is an ad-hoc hack. This sort of problem would benefit from some old-fashioned operations research-style statistical and mathematical modeling. What's the probability that a page will be needed? What's the cost of keeping it around? A proper model would be able to answer these questions. A "recency cache" and "frequency cache" is missing the bigger picture.
Re:Linux memory manager and your big data by ori_b on Wednesday November 27, 2013 @03:11PM (#6810792)
> What's the probability that a page will be needed? What's the cost of keeping it around?

The answer is pretty simple: It depends. What's your workload? There's no general answer.

So, Linux picked a heuristic. They could probably have picked a better one, but short of some sort all knowing of machine learning algorithm which can predict future workloads, the heuristic they pick will be suboptimal in some regard.

Re:Linux memory manager and your big data by jacques_chester on Thursday November 28, 2013 @12:17AM (#6813138)
> The answer is pretty simple: It depends. What's your workload? There's no general answer.

Which is, ironically, an argument for microkernels. In some microkernel designs you could, in principle, allow for applications to provide their own disk and memory managers.

Re:Linux memory manager and your big data by chris_wot on Thursday November 28, 2013 @05:22AM (#6813925)
There is nothing stopping the memory manager having tunable parameters from being added. Making core functions pluggable doesn't seem to be the way that the Linux developers want to do things, and I think it's probably justified (see the CFS debacle with Con Kolivas and his ideas around pluggable schedulers in the Linux kernel [1]).

Certainly it looks like there is some ideas that Johannes Weiner is considering for the future, and is actively working on with the set of patches he has merged:

  Future

  Right now we have a fixed ratio (50:50) between inactive and active
  list but we already have complaints about working sets exceeding half
  of memory being pushed out of the cache by simple streaming in the
  background.  Ultimately, we want to adjust this ratio and allow for a
  much smaller inactive list.  These patches are an essential step in
  this direction because they decouple the VMs ability to detect working
  set changes from the inactive list size.  This would allow us to base
  the inactive list size on the combined readahead window size for
  example and potentially protect a much bigger working set.

  Another possibility of having thrashing information would be to
  revisit the idea of local reclaim in the form of zero-config memory
  control groups.  Instead of having allocating tasks go straight to
  global reclaim, they could try to reclaim the pages in the memcg they
  are part of first, as long as the group is not thrashing.  This would
  allow a user to drop e.g. a back-up job in an otherwise unconfigured
  memcg and it would only inflate (and possibly do global reclaim) until
  it has enough memory to do proper readahead.  But once it reaches that
  point and stops thrashing it would just recycle its own used-once
  pages without kicking out the cache of any other tasks in the system
  more than necessary. [2]
1. http://apcmag.com/why_i_quit_kernel_developer_con_kolivas.ht...

2. https://lkml.org/lkml/2013/11/24/133

Re:Linux memory manager and your big data by ori_b on Thursday November 28, 2013 @02:13AM (#6813437)
To a degree. Both memory and disk bandwidth are shared resources. It's hard to prevent one algorithm from stomping on another without giving it exclusive control. So while you may be able to swap in a memory manager that doesn't have this pathological case, it might negatively affect other applications.

To give an extreme example, imagine that an application sets up a custom memory manager that takes all available RAM, and makes it exclusive to that application. In reality, it would probably be less insane, but you would still get regressions with multiple memory managers. And if you decide you have to have one true memory manager... you're back to the situation that exists today, only potentially slightly easier to configure away from bad behavior.

Re:Linux memory manager and your big data by jacques_chester on Thursday November 28, 2013 @09:57PM (#6817665)
Definitely, but my argument is that OSes must account for the shared-server case, but in practice many servers are dedicated to a single service.

Supposing you built a memory manager exclusively tuned for PostgreSQL, with the assumption that it has the machine to itself. That memory manager would have a different performance profile from the kind of "veil of ignorance" that a general-purpose memory manager has to cope with.

Re:Linux memory manager and your big data by mtdewcmu on Thursday November 28, 2013 @03:03AM (#6813542)
Applications can already manage their own memory in Linux. O_DIRECT bypasses the buffer cache when doing I/O, and there are plenty of ways that applications can influence or take control of their own memory using various system calls, many of which overlap or are redundant to some degree. It doesn't require a microkernel, and it's not new.
Re:Linux memory manager and your big data by mtdewcmu on Thursday November 28, 2013 @03:07AM (#6813549)
Right. There are lots of state of the art algorithms in Linux. If there was a published solution that was obviously much better, you can bet it would be implemented.
Re:Linux memory manager and your big data by rodgerd on Thursday November 28, 2013 @03:04PM (#6816167)
You'd like to think so, but some of the intransigence around scheduling and tracing would suggest that's not always the case.
Re:Linux memory manager and your big data by mtdewcmu on Thursday November 28, 2013 @03:45PM (#6816360)
I don't follow the kernel discussions, but since scheduling algorithms always create winners and losers, you can imagine why there'd be resistance to change.
Re:Linux memory manager and your big data by rodgerd on Friday November 29, 2013 @01:57AM (#6818217)
In the case of scheduling we have the bizarre situtation where we have pluggable IO schedulers for different workloads, but a blank refusal to allow the same for CPU scheduling.
Re:Linux memory manager and your big data by phaemon on Wednesday November 27, 2013 @04:49PM (#6811385)
Well don't just post this here. Post on the Linux Kernel Mailing List. If you can explain to them how to improve their ad-hoc hack, I'm sure they'd love to hear from you. It would almost certainly be hugely valuable to companies like IBM or Google to have better memory management on their servers. In fact, it could probably boost Linux performance on the Supercomputer list!
Re:Linux memory manager and your big data by dllthomas on Wednesday November 27, 2013 @05:01PM (#6811456)
And they'll be super friendly about it.
Re:Linux memory manager and your big data by phaemon on Wednesday November 27, 2013 @05:15PM (#6811532)
I would pay money to watch it.
Re:Linux memory manager and your big data by joe_the_user on Wednesday November 27, 2013 @04:25PM (#6811251)
Well,

Keep in mind that never, ever having really bad things happen is first priority for an algorithm of that sort and only then can it think about being efficient in a really clever way.

I'd imagine that from the statistical analysis perspective, all memory managers seem like "ad-hoc hacks" but I believe what happens is they are really smart hacks tested with multiple use cases.

Creating a statistical analysis/machine-learning/etc program that can deal quickly with heterogeneous data robustly in real-time would be an incredible achievement.

If anyone knows of a situation where serious machine learning has been applied at such a low level, I would love to hear about it (the only thing vaguely similar I recall is that use of neural networks for branch prediction, something that's been studied but not implemented).

Re:Linux memory manager and your big data by zidar on Wednesday November 27, 2013 @08:29PM (#6812504)
You should look up some links in the article (proposed solution https://lkml.org/lkml/2013/11/24/133)

"Currently, the VM aims for a 1:1 ratio between the lists, which is the "perfect" trade-off between the ability to protect frequently used pages and the ability to detect frequently used pages. This means that working set changes bigger than half of cache memory go undetected and thrash indefinitely, whereas working sets bigger than half of cache memory are unprotected against used-once streams that don't even need caching."

Re:Linux memory manager and your big data by blt on Wednesday November 27, 2013 @06:03PM (#6811806)
I was under the impression that this code has to be really fast. I wonder how much computation they can get away with.