Nat! bio photo


Senior Mull

Twitter Github Twitch


So I am sick at home, can't go to work. What do I do ? Code something...

I had this idea for a NSAutoreleasePool implementation, that I figured would be faster than what Foundation offers. Actually it isn't even sporting. You write down some straightforward code, measure and win. :) It's that easy. Foundation needs a little less than 2 minutes for adding securely retained objects and releasing them (the object is never ever deallocated). And the MulleAutoreleasePool code does it in 9 seconds...

2003-12-15 16:00:51.160 MulleAutoreleasePool[26323] Preparing 10000 objects...
2003-12-15 16:01:00.881 MulleAutoreleasePool[26323] Adding 100000000 objects to NSAutoreleasePool
2003-12-15 16:01:11.756 MulleAutoreleasePool[26323] Killing NSAutoreleasePool
2003-12-15 16:02:54.987 MulleAutoreleasePool[26323] Adding 100000000 objects to MulleAutoreleasePool
2003-12-15 16:02:58.324 MulleAutoreleasePool[26323] Killing MulleAutoreleasePool
2003-12-15 16:03:03.380 MulleAutoreleasePool[26323] Done

Well, well well. Things look a bit differently though, if we reduce the number of objects to a tenth. Now the MulleAutoreleasePool does it in a second, whereas Foundation "only" used 2 1/2 s.

2003-12-15 16:07:18.969 MulleAutoreleasePool[26332] Preparing 10000 objects...
2003-12-15 16:07:19.971 MulleAutoreleasePool[26332] Adding 10000000 objects to NSAutoreleasePool
2003-12-15 16:07:20.894 MulleAutoreleasePool[26332] Killing NSAutoreleasePool
2003-12-15 16:07:22.357 MulleAutoreleasePool[26332] Adding 10000000 objects to MulleAutoreleasePool
2003-12-15 16:07:22.682 MulleAutoreleasePool[26332] Killing MulleAutoreleasePool
2003-12-15 16:07:23.180 MulleAutoreleasePool[26332] Done

For whatever reason at a certain amount of objects NSAutoreleasePool really slows down a lot.

There is no point at which NSAutoreleasePool overtakes MulleAutoreleasePool. Unfortunately for me, I thought I could cleverly optimize the "releasing of the pool objects" code , but instead its my "adding an object to the pool" code that is much better.

So expect an article in the Optimizing Objective-C series sometime in the near or distant future. Though feature complete I'd like to stick the MulleAutoreleasePool in a few threaded apps and see if it behaves well. (It should).