Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: zero filling pages



On Wednesday, July 23, 2003, at 5:50 PM, Nat! wrote:
Jim Magee <email@hidden>
(they can re-zero fill only if its stolen in the meantime) via msync(MS_KILLPAGES or MS_DEACTIVATE) calls. All this without the overhead of releasing and re-acquiring the address space for the pages to sit in.

Aha! Is there a rule of thumb, when it is better to vm_deallocate pages than to keep them cached for reuse and msync them ? (I believe that vm_deallocate does a little defragmentation...)

I think this is going to be application dependent. Our general rule was it was better to just vm_deallocate() them (from profiling "typical" large allocation patterns in malloc()) so that's why the default [scalable malloc zone] algorithm does that. You, obviously, see a different pattern in your application (maybe you free and re-allocate large regions more often than is typical of all applications). So, you would need to find your own algorithm.

But here are some things to consider:
- Killing a page will take about 4-6us total with an optional zero-fill fault(4-5us) if it gets stolen later.
The cost of the kill can be amortized over a range of pages - but there is still per-page overhead.
Total overhead: between 4 and 11us per page (slightly lower if large ranges in play)

- Deallocation (~4us), re-allocation (~4us) and zero-fill faulting (4-5us).
The cost of the allocation and deallocation may be amortized over several pages - with no per page overhead.
Total overhead: ~12us per page (much lower if large allocations in play)

- Swapping a page in and out will cost ~20ms total.
If the data is useless to you (and you have no assurance that you are going to come back and reuse/re-
reference it in the quite near future), do one or the other of the above. But if you KNOW you are going to
keep the pages hot, do this (zero cost per page).

--Jim
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: zero filling pages (From: Nat! <email@hidden>)



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.