| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
> Run, do not walk, to mmap(2).
running -- slowly.
> P.S. By the way, handles are completely unnecessary in Mac OS X...
I've read that but my feet are heavily weighted by practice of using handles.
Thank you for reminding me.
W.
----------------------
Message: 6
Date: Tue, 29 Mar 2005 21:49:28 -0800
From: Chris Espinosa <email@hidden>
Subject: Re: performance issues
To: "Carbon Dev." <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset="us-ascii"
On Mar 29, 2005, at 3:42 PM, Edwards, Waverly wrote:
> Would someone provide me with some tips for getting the most
> performance out of my operating systems / virtual memory.
>
> I have a 378 megabyte file that I
>
> 1. read the entire file into a handle
Stop right there.
Don't do this.
You'll just end up making a copy of the file on disk (in the form of
your 378Mb being swapped out to VM).
Run, do not walk, to mmap(2).
http://developer.apple.com/documentation/Darwin/Reference/ManPages/
man2/mmap.2.html
Yes, you'll have to learn how to handle POSIX-style system calls in
your Carbon app, but it isn't that hard. But what this does is it
logically joins your file to the virtual memory system, so that each
block of the file behaves as if it's already in your memory space.
Now given that, if you walk through a 378Mb file and touch every page,
yes, there will be a lot of disk I/O. But far less than if you try to
read the whole file in, fault half of it out, fault back in the first
half to write to it, fault it out to write it, fault the second half
back in, etc.
Chris
P.S. By the way, handles are completely unnecessary in Mac OS X, except
for backwards-compatibility with Carbon functions that take them. With
Mac OS X's VM system, you can resize a pointer just as easily as you
could resize a handle in Mac OS 9.
"Mac OS X implements a highly-tuned, threadsafe allocation library,
providing standard implementations of the malloc, calloc, realloc, and
free routines, among others. If you are allocating memory using older
routines such as NewPtr or NewHandle, you should change your code to
use malloc instead. The end result is the same since most legacy
routines are now wrappers for malloc anyway."
http://developer.apple.com/documentation/Performance/Conceptual/
ManagingMemory/Concepts/AboutMemory.html
----------------------------------------------------------------
Waverly Edwards
NA Support Center
Genesys Conferencing - Reston
Email - email@hidden Phone: 866-343-HELP/4357
Direct: 703-736-7121
_______________________________________________ Do not post admin requests to the list. They will be ignored. Carbon-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/carbon-dev/email@hidden This email sent to 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.