| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
On Sunday, June 22, 2003, at 4:36 AM, Marcel Weiher wrote:[fairness]
You seem to be making the assumption here that "fairness" is an inherent good. I feel no inherent moral imperative for treating memory pages fairly.
Sorry, I didn't mean to make any moral judgments.
It also has the benefit of being quite predictable. Where it isn't desired, there are simple ways around it (as I pointed out with msync(), and the no-cache fcntl() options).
Other algorithms, many of which have been (and continue to be considered), tend to make prediction of the policy more difficult for the multimedia software that is the bread and butter of Mac OS X.
And lets face it, when you try to run those kinds of applications on a system that is by nature way over-committed in memory resources, being able to predict the default behavior is important.
[mapped pages are already 'punished']
In theory, maybe. In practice, the system will push everything else out of RAM onto disk in favor of the mapped file.
If the current application _needs_ to bring in a bunch of mapped file pages in order to function properly, it better be able to.
If that means we had to swap some not-used-recently heaps from other applications - so be it.
A little thrash when the user actively switches apps is better than denying an opportunity for an application to run at all in the limited resources available to it.
And, again, for many of the key [data intensive] multimedia applications in our key markets, running degraded is worse than not running at all.
mmap() seems to allocate and retain memory very aggressively in OS X. When I mmap() a large file (~200 MB in size) read-only and access it sequentially from start to end, the RSIZE of my program quickly grows to the size of the file. If the free physical memory is insufficient to accomodate the whole file, the system starts swapping heavily: first other data is paged out (running applications etc), then (after my application has finished and when the paged-out applications are needed again) it has to be swapped back in. During this time, the system is very unresponsive. The whole process can take several minutes.
Huh? The assumption you seem to be making here is that with sequential, we need to know exactly when a page is 'done' so we can then immediately discard it. Why? All that is necessary is to know that when memory is tight, you start discarding sequential pages from the start of the sequential region. No clairvoyance required!
Surely you don't mean "and take ALL the sequential pages (including the ones the app hasn't finished with yet)
before we take ANY pages that need to be swapped (even though the pages that need to be swapped are MUCH older and not currently needed)?"
But anything else does require some clairvoyance again. Again, how far back do we need to keep?
Believe me.
Many algorithms that try to guess at the relative importance of "slightly" older sequential pages vs. "much" older swappable pages have been examined. For instance, ones that age sequential pages 2, 3, or even 10 times faster than other [swappable] pages have been tried and STILL tend to push the system over the knee of the swapping curve anyway.
Worse, they also tend to cut the knees out from under multimedia applications much sooner (often long before a crisis really exists).
So, after all that, we have found that there are far fewer applications that benefit from those altered algorithms than not. And most of those are much simpler, and can easily be modified to describe their desire to NOT participate in LRU for a particular set of pages.
After all this well-mannered debate,
it seems it comes down to an issue of you liking the semantics of madvise() for making that indication rather than msync().
I'll see what I can do to make both equally as effective.
| References: | |
| >Re: Strange behaviour of mmap() in OS X (From: Jim Magee <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.