• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Speed Traps
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Speed Traps


  • Subject: Re: Speed Traps
  • From: Nat! <email@hidden>
  • Date: Wed, 21 May 2003 02:02:26 +0200

Am Dienstag, 20.05.03 um 02:48 Uhr schrieb Marcel Weiher:

On Monday, May 19, 2003, at 11:22 Uhr, Nat! wrote:


I remember I actually once reverted back from inline ref counting to the Apple way, when I wrote the MulleSybaseEOAdaptor. When I implemented inline ref-counting on certain classes, things went slower, when I was fetching a lot (really a lot!) of objects.

And none of these objects were stored anywhere, like in arrays, dictionaries? How did you keep track of them if there were such a lot of them? Interesting...

Of course, there may be a way to get this, if you implement collections with methods like "addObjectAndRelease:" or "setAndReleaseObject:forKey:". These could get away with keeping the reference count at 1 (with the retain for storing and the release in the method name cancelling each other and the reference count not being touched).

Or maybe AddButDontRetain: :)

For an example, using Foundation code only, mentally replace dictionary with NSMapTable and the NSNonRetainedObjectMapKeyCallBacks or NSNonRetainedObjectMapValueCallBacks.


Then I figured it like this (It's been a while, but I think I stil got it about right)

If your objects stay at a retain count of 1, then the Apple code does not need to create an entry in the hash table (1 being the default for an object), this saves 32 bit.

Yes. It turns out that all of the Apple objects I looked at use less than a full word for the inline reference count, by sharing with some other variable that didn't mind losing a few bits...

The decrease in speed I saw, was probably due to the fact that (quite a few) more memory pages had to be allocated from the OS, for the inline reference count overhead (my objects were small).

The merit of the default implementation is still dubious IMO, nevertheless it would be interesting to figure out how many objects typically in their lifetime exceed a retain count of 1.

All that are (a) stored in instance variables or (b) stored in collections, even if only temporarily.

Yeah well, I really meant a quantitative figure. For example how many objects are temporarily created and as quickly forgotten as in code analog to this :

s = [s objectByAppending:x];
s = [s objectByAppending:y];
s = [s objectByAppending:z];

If they were a large percentage of all objects generated, it would be a win. That would be need some testing "Aber das ist harte Arbeit. Das schdtzen wir nicht!" :)

Ciao
Nat!

Jedenfalls sind zehn Fehlstarts hintereinander [E. Fuchs]
ein sehr interessanter Beweis
fuer unsere Theorie
von der natuerlichen Ueberlegenheit des Dezimalsystems
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Undo menu not enabling with NSMovieView?
      • From: m <email@hidden>
    • Re: Speed Traps
      • From: Ben Dougall <email@hidden>
References: 
 >Re: Speed Traps (From: Marcel Weiher <email@hidden>)

  • Prev by Date: try / finally
  • Next by Date: File Package without NSDocument
  • Previous by thread: Re: Speed Traps
  • Next by thread: Re: Speed Traps
  • Index(es):
    • Date
    • Thread