From: Christian Szegedy Date: 2002-08-29T08:51:44+09:00 Subject: Re: Temporary VALUE Needs to Be Protected? William Djaja Tjokroaminata wrote: > Hi, > > Yes, I probably feel the same way as you do. The more I know about the > extent of the Ruby garbage collector, the more concerned I am with its > impact on execution performance. > > I think I am using Ruby in some sense not in its original intended > purpose. For my current application, I am using Ruby more like "a user > interface" then a full-blown programming tool. The core computation is > done in C and therefore for efficiency purpose I have moved a lot of data > to C struct members instead of Ruby's "@" internal data. > > As I am trying to separate Ruby object model from its memory management, > issues like this really come out. Has anybody really done a C programming > in the presence of a (mark & sweep) garbage collector (besides doing C > programming within the scripting languages)? > > Regards, > > Bill > ============================================================================ > Mauricio Fern?ndez wrote: > >>On Wed, Aug 28, 2002 at 06:03:41PM +0900, Christian Szegedy wrote: >> >>>The Ruby garbage collector scans the used part of the stack, >>>and registers all addresses found there. This may be too much, >>>but it does not matter. (That was matzs commment about the >>>"conservativness of the gc") >> > >>What is the performance impact of Ruby's GC being conservative? >> <=> How large is the C-stack usually? > > >>Couldn't we use some preprocessor-magic to mark the pointers as they're >>created? > I don't have not made any tests but my intuition says that under normal circumstances, the size of the (used part of) stack must be fairly negligible compared to the heap, therefore, it should not make significant overhead. I think, mixing C-style allocations and Ruby style Objects is fairly trivial in Ruby. If your C-structure does not reference any Ruby object, then you don't need to mark anything. OTOHS, you have to mark every referenced Ruby object. Under normal circumstances, it should not be too hard... Of course, Rubys GC is far from optimal, but it is still quite OK for most applications. Besides this, you can switch it off (temporarily), or trigger GC if you think it is appropriate in certain situations. Regards, Christian