News for hackers. Stuff that matters.
Re:Assault by GC by JoeAltmaier on Monday October 24, 2011 @09:19AM (#3149462)
Then you have to manage their lifetimes 'manually'. Iterate, ultimately you remove GC altogether.

If GC is the future (and it seems it is) of language runtime, then some kind of control will be needed for situations like this. Different pools, explicit tagging of 'long-lived' or 'cache value' or some such during allocation?

Re:Assault by GC by scott_s on Monday October 24, 2011 @02:22PM (#3150854)
Iterate, ultimately you remove GC altogether.

I think that's reductio ad absurdum. It's typical in long-running applications to have a class of memory unlike the rest, that will live the entire lifetime of the application. I see no problem with being able to tell the GC "this memory will always be used," or just allocating it outside of the GC entirely, while still wanting all of the benefits of GC elsewhere in the application.

Re:Assault by GC by jerf on Monday October 24, 2011 @01:29PM (#3150605)
"Different pools, explicit tagging of 'long-lived' or 'cache value' or some such during allocation?"

The idea that immediately came to my mind is that given that the site is probably load-balanced, the best thing to do would be to take the site out of the load balancer while the big GC runs, then put it back in. I wonder if there's some way to hook that GC event. So, "pools", but at a higher level.

Re:Assault by GC by tedunangst on Monday October 24, 2011 @03:52PM (#3151273)
There is. I'm surprised they didn't try it.

http://msdn.microsoft.com/en-us/library/cc713687.aspx

Re:Assault by GC by sams99 on Tuesday October 25, 2011 @04:07AM (#3153265)
Really?

We register for notifications from the GC using a magic threshold number that could mean anything.

Then we quickly notify the rest of the webs a GC is pending on our "message bus". They let us know they are safe from GC at the moment. If they are not you are in a pickle.

Then we notify HAProxy that we are about to run a GC and ask it to tell us when it is done draining the current requests and taking our web offline.

Once notified we perform the GC manually

Then we notify HAProxy that we are done with the GC so it can add us back to the pool.

What could possibly go wrong?

Re:Assault by GC by JasonPunyon on Tuesday October 25, 2011 @05:20AM (#3153415)
2 magic threshold numbers that could mean anything :)
Re:Assault by GC by tedunangst on Tuesday October 25, 2011 @11:58AM (#3154505)
Or you could just tell haproxy you're going to be low priority for a little bit and not worry about every single last request never being processed on GCing server.
Re:Assault by GC by sams99 on Wednesday October 26, 2011 @01:49AM (#3157366)
you do realise that only about 0.09% of our requests were affected by this, catching them all is the whole point here.
Re:Assault by GC by jerf on Monday October 24, 2011 @03:58PM (#3151311)
Thank you. I'm not a Windows dev so I didn't expect I would necessarily be able to find it very quickly.

Reading that page it is clear that this is either the exact scenario that page is covering, or at the very least one of the core use cases.

It's triggering my Wrong Thing To Do senses, but, well, when the GC isn't quite right, hacking around it may be the only option.

Re:Assault by GC by fpgeek on Monday October 24, 2011 @10:22PM (#3152541)
I think you've got it exactly backwards. By the time you've dealt with some of the various complexities manual memory management, for example:

  - handling memory with a dynamic lifetime 
    (with cycle detection as an important corner case)

  - improving allocation performance

  - preventing heap fragmentation

  - thread-local allocators (for multi-threaded scalability)

  ...
I think you're approaching a garbage collector. In fact, I'd even go so far as to say there is a memory-management analog for Greenspun's tenth rule:

Any sufficiently complicated, long-lived program that manually manages memory contains an ad hoc, informally-specified, bug-ridden, slow implementation of a garbage collector.

I agree there's a place for some amount of "hinting" to the garbage collector about the lifetime of some special objects, but, to me, the important thing is that you only need it for the extreme cases.

Re:Assault by GC by rayiner on Monday October 24, 2011 @02:21PM (#3150847)
It's possible and practical. The MPS allows you to have manually-managed pools alongside GC'ed pools in the same heap: http://www.ravenbrook.com/project/mps/

Useful for long-lived data that doesn't change frequently.

Re:Assault by GC by mseebach on Monday October 24, 2011 @11:16AM (#3149953)
That is what Terracotta BigMemory is supposed to do for the JVM. It gives you a way to store Java objects off the heap and thus away from the GC.

http://terracotta.org/products/bigmemory

Re:Assault by GC by oconnor0 on Monday October 24, 2011 @02:44PM (#3150944)
Are you aware of any other solutions for the JVM? Preferably open source.
Re:Assault by GC by elefont2 on Monday October 24, 2011 @03:06PM (#3151027)
There is an apache incubator project

http://raffaeleguidi.wordpress.com/