How Snow Leopard Cut ObjC Launch Time In Half
MBCook writes "Greg Parker has an excellent technical article on his blog about the changes to the dynamic linker (dyld) for Objective-C that Snow Leopard uses to cut launch time in half and cut about 1/2 MB of memory per application. 'In theory, a shared library could be different every time your program is run. In practice, you get the same version of the shared libraries almost every time you run, and so does every other process on the system. The system takes advantage of this by building the dyld shared cache. The shared cache contains a copy of many system libraries, with most of dyld's linking and loading work done in advance. Every process can then share that shared cache, saving memory and launch time.' He also has a post on the new thread-local garbage collection that Snow Leopard uses for Objective-C."
In other words, Apple just re-invented Superfetch
Photocopiers anyone?
snow leopard stories!
I take it since then shared library machine code has had to be patched in memory after it's loaded for a while now, thus preventing easy sharing among processes, and causing the page to need its own space in the swap file.
Sounds like this latest improvement effectively brings things back to the way they were, by effectively writing this patched version back to disk so that it can be mapped read-only as before, and not have to be patched every time the library is loaded into a process. It's odd, because I thought the OS already did this several versions ago when prebinding.
dyld - noun. A reminder that regardless of age, you'll always have an adolescent sense of humor.
Sounds like they've just updated their dynamic (shared) library loader to be able to handle Objective C (aka Cocoa) instead of just plain C, and to be a little smarter about keeping track of what it's already got going on, so it doesn't duplicate things.
As a long-time UNIX and Linux (and other more esoteric OSes) geek, this alone doesn't impress me too much. The idea that they went through the whole OS and worked to get little efficiency/performance gains like this all over the place impresses me a little more.
Village idiot in some extremely smart villages.
So, Snow Leopard is now doing something Windows has always done... how is this news?
Jibe!
a sad world. at
What's the difference between this and sticky files?
I do not wish to be a poo poo, but since dynamic libraries and shared libraries have been around for just about forever, when even a second year CS major would immediately notice this could be done, is such big news now?
The first thing I would have done is built a cache for the library system. LINUX has one, why not the Mac?
So certainly I congratulate the Mac community. But wow, DUH, a cache for the linkage editor. :-)
-Hack
Got Geometrodynamics? Awe, too hard to figure out? Too bad.
Too bad I had to restore my computer to Leopard.....because with all this whiz-bang technology, many of my applications started to crash when saving files. I lost a days time updating and then restoring my two macs.
The shared libs are shared. What was not shared before is the linking table, that must be built for accessing that shared code. prelink precalculates that table, and this apple thing does more or less the same.
I'm not sure whether there are people out there writing Objective-C apps for the Mac without Cocoa, though. I guess there's always someone who won't use the nifty library and shortcuts and all that, because they're hardcore, efficiency nuts, or just masochists...
Or they use only a subset of Cocoa because they plan to port the app to GNU/Linux, *BSD, and Windows using GNUstep, an OpenStep-compatible toolkit that implements only some of Cocoa.
SGI did this linking trick in the early '90s - they called it Quickstart.
Objective-C uses a two-phase dispatch for method calls. When you see a call in the Objective-C source code that looks like:
the dispatch system:
C++ follows the same steps. The big difference is that in Objective-C, the dispatch table is an associative array (C++ unordered_map, Java HashMap, Python dict) from strings to function pointers, not a plain array (C++ vector, Java ArrayList, Python list).
In my opinion as an experienced application developer the user should never run into the problem that Superfetch attempts to solve. Anti-malware scans or backups are generally limited by I/O transfer rates, not by CPU. In such situations, using lots of memory to pre-load data makes no sense. It is relatively easy to write a two-buffer, threaded, streaming system for situations that are constrained by disk transfer rates without consuming scads of memory.
But then you rely on the operating system to provide a method for applications to provide cache hints, and you rely on the antivirus software to provide such hints. SuperFetch tries to infer these even for applications developed prior to widespread knowledge of these hints or ported from systems that lack these hints.
In the bigger picture, Superfetch attempts to learn the times of day when apps are used and pre-loads their binaries. This is a nice concept, but I have serious doubts as to how useful it really is.
Having my applications ready to start at 08:57 when I'm about to grab the mouse at 08:58 improves my productivity. Consider that employees have sued their employers for requiring that employees be present during application startup time but not paid until the application has fully started up.
Mac OS X is less likely to need such anti-malware scans in the first place as the application binaries are now digitally signed by the developer.
But who signs the developer's certificate? And what keeps malware publishers from signing their trojans?
Any malware that attempts to insert itself into applications will run into problems.
Unless an application tries to insert itself as, say, an assistive technology using the accessibility API.
A lot of people seem to be confused about operation of "shared" libraries.
Shared libraries on most platforms (mac,linux,windows..etc) are "shared" within a single processes memory space only. They are NOT "shared" between processes. Each separate process instantiates libraries separatly.
Apples change is to globally save some library state data to reduce each processes instantiation overhead when common libraries are used by multiple processes.
Perhaps Obj-C has a few nice features but personally I don't see it. If they'd stuck to C or C++ like every other version of Unix then this would never have been an issue in the first place. Plus a lot more people would have been able to cross-code for OS/X without having to learn an obscure OO version of C which never caught on in the wider IT world and is still used on practically no other system.
"In other words, Apple just re-invented Superfetch" - by LO0G (606364) on Sunday September 06, @10:36AM (#29331275)
On that note? Well, I could say that Microsoft only "ripped off" ideas I've been using since the early 1990's (first on software ramdisks, & later on SSD's too, per how I use them noted in this post here on /., today (& long before THAT, many times here & elsewhere online)):
http://hardware.slashdot.org/comments.pl?sid=1359547&cid=29332071
Microsoft's only using a VARIATION OF MY IDEAS.
Ideas that took EEC Systems/SuperSpeed.com to a FINALIST position @ Microsoft's own Tech-Ed, 2 yrs. in a row, in its hardest category: SQLServer Performance Enhancement, albeit not for "home/end user oriented tasks" (which I list some of above & how I use it @ home @ least)...
That was for "back office app" perf. enhancement, & that url above shows proofs of that much for WebServers, File Servers, & DB Servers (from TechReport.com, in regards to Webserver, FileServer, & DB Server performance gains when using a TRUE SSD, like the IRAM).
E.G.-> AND? When that work showed improvements on SQLServer 6.5 & below, which used HDD space for various ops? Microsoft later "turned around", & made those ops take place in RAM...
(Which amounts to the SAME THING as doing it on a ramdisk in software really, & MUCH FASTER than HDD space could do it (MS uses a dedicated array/buffer in RAM now in SQLServer, because it works, for superior performance on DB work, bigtime)).
APK
P.S.=> More proof of my involvement here in this arena, goes back in WRITTEN PUBLICATION no less, as far back as 1996, here:
Windows NT Magazine (now Windows IT Pro) April 1997 "BACK OFFICE PERFORMANCE" issue, page 61
(&, for work done for EEC Systems/SuperSpeed.com on PAID CONTRACT (writing portions of their SuperCache program increasing its performance by up to 40% via my work) albeit, for their SuperDisk & HOW TO APPLY IT, took them to a finalist position @ MS Tech Ed, two years in a row)... apk
Also, so what if they're "different languages"? If they were the "same language" there'd be nothing to compare. Do you go around comparing your right eye to your right eye?
Over-the-top Response Guy! Giving "Over-the-Top Responses" since 1970.
or chair, return they started to Thes3 eArly OpenBSD, as the
Why don't they (any OS) just add something onto the generic filesystem caching layer to keep executable bits in RAM as long as the input files stay the same? If it was done that way you could theoretically reuse it for interpreted code as well.
Perhaps Obj-C has a few nice features but personally I don't see it. If they'd stuck to C or C++ like every other version of Unix then this would never have been an issue in the first place.
But you can use either of those perfectly well mixed with ObjC calls.
ObjC is a relatively small set of additions to standard-C, so it really doesn't take that long to pick up the syntax changes if you've encountered C before, while at the same time it allows for some very nice dynamic behavior and things like introspection. The language has evolved to support things like garbage collection (though that specific feature is not available on the iPhone due to performance constraints).
What you are really overlooking though is that Objective-C that Apple uses, has a very rich and diverse set of foundation classes (some inherited from the NeXT days) - just as wide in scope as Java. Any modern language simply has to have a giant toolbox to help get common tasks done, and that's going to be the thing that takes the most time to learn. Happily, Objective-C has a fairly consistent set of tools and conventions, that make learning new parts easier once you have learned a few others.
"There is more worth loving than we have strength to love." - Brian Jay Stanley
I'm not so sure about that. Typically, code in shared libraries is re-entrant and code pages are loaded once, then mapped into the address space of the process using them. I don't know of any modern OS that wastefully makes a copy of the library's code for each process.
I don't know about other platforms, but I wouldn't be surprised if they do something to share the memory as well.
They probably just rolled in the 2.6.31 kernel.
Using OS X/Mac since 10.2.8, I haven't seen another abused tool like "update_prebinding" even while it is a very risky process in pre 10.5 systems since it deals with actual binary headers.
Also thanks to uninformed IT blogs etc, people always considered prebinding a thing which will go away in next release. Like, Apple is really stupid to do such thing. They basically misunderstood the added flexibility to prebinding scheme where tools without (or broken) prebinding will continue to run.
Anyway, want to see how much Apple users are abused by some shareware developers? Just watch for a applescript to basically issue this command and asks for money or donation. I don't have 10.6 but on 10.5, in its FIRST line of man page (man update_prebinding), Apple states "normally, there shouldn't be any need to issue this command manually" or something equivalent to that. On pre 10.5, like 10.4.11, it can get catastrophic if you keep doing it, as explained on article http://unsanity.org/archives/mac_os_x/shock_and_awe.php
Unless you lived a power loss in middle of a OS X/Quicktime update or kernel crash, there shouldn't be ANY reason to manually update prebinding. In fact, it can lead to a horrible cache fragmentation which may slow things down. Don't fix a working thing.
Listen to your "theme song", by them. It's entitled: "I'm a LOSER"
APK
P.S.=> Fits you, perfectly... you've never done anything worth anything, & it shows. You truly are, the "ANONYMOUS COWARD", & because of that? You'll never amount to anything, & that is that... apk
Dude, I think you're hearing things that people aren't saying. The article describes how apple has improved their dynamic loading. The author doesn't claim they invented it. Apple doesn't claim they invented it. Nobody said anything about amazing new technologies Apple created.
College-Pages.com - Online Colleges, Degrees, and Programs
I just checked and a 1-year code signing cert from Comodo is $179.95, with discounts for multi-year certs. Other vendors also seem to have pretty reasonable prices.
That's at least on the order of $100 per platform. The certificate for Windows is $179.95 per year, and the certificate for a secure web site from which to distribute copies of the software is another $99 per year. It gets even more expensive to target more than one platform: the certificate for XNA is $99 per year, the certificate for iPod Touch is $99 per year, and by the time one has ported an application to all the platforms that his audience uses, he'd be out of his hobby money.
Anyone who has the time to put together a serious app (even for freeware) can afford that amount.
Say I develop a video game and want to distribute it to the public. How would I recover the nearly $480 per year across three platforms without selling either copies or advertisements? It's almost enough to push someone toward a less expensive hobby.
See subject line above, & rinse/lather/repeat.
See subject and lay off the profanity and coffee.