Thomas Tempelmann on file system speed on OS X
Thomas Tempelmann posted a neat little piece on the features and abilities of CoreFoundation's File Manager (formerly known as the Carbon File Manager). Particularly he mentions how its FSRef architecture gives you much better performance for file listing than the path-based POSIX APIs. A short but informative read for anyone who has to do a lot with files.
|Aaron Ballman writes:|
So that makes me curious: does Apache on the Mac use POSIX paths, or FSRefs? What about other file-system intensive applications? Surely the path/inode-based APIs aren't going to be exponentially slower than FSRef APIs. I doubt Apple re-wrote all of the core utilities (ls, find, etc) that make up the OS to use File Manager calls instead, and the system is certainly responsive enough.
Aaron the point is not that paths are slower on OS X than on other systems, but that FSRefs are inherently faster than paths. (In potentia, anyway; obviously they could be implemented badly.)
|Jean-Daniel Dupas writes:|
If you want to be exact, it the Core Services's File Manager, not the CoreFoundation's one.
I really like the FSRef concept and miss it when I have to work on other system.
I hope futur OS X file systems will keep this concept.
|Uli Kusterer replies: ★|
@jean-daniel Thanks for the correction. Peter Hosey also mentioned that it's actually in CoreServices, and of course you're both right.
|Thomas Tempelmann writes:|
I just found this page after asking ask.com "who is" me. Everyone does that sometimes, don't you?
Anyways. Snow Leopard (10.6) will introduce a new API that replaces FSRefs with CFURLs - those are, other than FSRefs, reference counted, which allows the OS to manage the needed refs and discard of the obsolete ones. Which is important on Macs that access a lot of remote volumes, where the ref information wouldn't fit into a FSRef (which is a container of a fixed size, i.e. 80 bytes). CFURLs get dynamically alloc'd and the user only holds a ref to it. That way, the lower FS levels are able to define the amount of storage the need for a ref to an object of their domain.
So, from 10.6 on, forget paths, forget FSRefs, be merry with CFURLs!