• 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: Performance problem with GC enabled
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Performance problem with GC enabled


  • Subject: Re: Performance problem with GC enabled
  • From: Peter Ammon <email@hidden>
  • Date: Fri, 13 Mar 2009 17:26:26 -0700


On Mar 13, 2009, at 4:47 PM, John Engelhart wrote:

On Thu, Mar 12, 2009 at 3:17 PM, Peter Ammon <email@hidden> wrote:

Hi John,

Instead of storing each string individually into the heap, try batching up,
say, 1k or so into a stack allocated buffer. Then use
objc_memmove_collectable() to move them in bulk into the heap at the point
your stack allocated buffer gets full, or your scan finishes.



I actually did give this a shot, or something close to it. I tried using just the stack (swapping NSAllocateCollectable() with alloca()), but no joy- exactly the same times came out. Good call though.


That wasn't quite my suggestion, and I would not expect that to result in any improvement. If you store an object through an arbitrary pointer, the compiler will use a write barrier. I doubt the compiler will figure out that because the memory came from alloca(), it is on the stack.


The goal is for the compiler to not use individual write barriers at all, and it won't for stack allocated buffers. So my suggestion is to make a buffer that the compiler knows is on the stack:

id stackBuffer[1024];

Stores to that buffer will not go through write barriers. When that buffer is full, use objc_memmove_collectable() to move it to the heap.

I wrote a quick test to try this and it resulted in a 10x speedup compared to individual write barriers.

-Peter

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Performance problem with GC enabled
      • From: John Engelhart <email@hidden>
References: 
 >Performance problem with GC enabled (From: John Engelhart <email@hidden>)
 >Re: Performance problem with GC enabled (From: Peter Ammon <email@hidden>)
 >Re: Performance problem with GC enabled (From: John Engelhart <email@hidden>)

  • Prev by Date: Re: EXC_BAD_ACCESS on NSImageView::setImage
  • Next by Date: Re: TXT Records with NSImages
  • Previous by thread: Re: Performance problem with GC enabled
  • Next by thread: Re: Performance problem with GC enabled
  • Index(es):
    • Date
    • Thread