TempAlloc and druntime GC
dsimcha
dsimcha at yahoo.com
Mon Jan 19 19:28:00 PST 2009
== Quote from dsimcha (dsimcha at yahoo.com)'s article
> One more note: It would also be greatly appreciated if you would expose a version
> of GC.malloc that returns null on failure instead of throwing an exception. For
> performance, TempAlloc treats out of memory as non-recoverable. This is necessary
> because, since scope statements are often used to manage freeing, the performance
> hit from having TempAlloc-related functions be throwing would be too large. Also,
> making TempAlloc functions non-throwing by catching outOfMemoryErrors and aborting
> is in itself expensive.
> Furthermore, I just realized (literally while I was writing this post) that C's
> malloc (which I use only b/c it doesn't throw) doesn't always return 16-byte
> aligned pointers like druntime's. Ideally, I'd like to stop using the C heap and
> start using the druntime heap, but I can't do that until there is a non-throwing
> implementation of GC.malloc.
Never mind as far as this. I realized that the reason why the try/catch blocks
were costing so much performance is because I was doing them inline and in some
cases putting them around a whole bunch of code. This was probably killing a lot
of compiler optimizations. When I instead did it the non-stupid way and wrote a
wrapper for malloc, this no longer resulted in a significant performance penalty.
More information about the Digitalmars-d
mailing list