Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How long should I expect a garbage collection to take before removing an opaque FFI object? Is it possible to speed it up some way?

I consider writing Haskell bindings to a quantum mechanics library written in C++ (I'd write a plain C wrapper) and CUDA. A major bottleneck is always the GPU memory used by the CUDA parts. In C++, this is handled quite efficiently because all objects have automatic memory management, i.e. are erased as soon as they leave scope. Also I use C++11 move semantics to avoid copies, those obviously wouldn't be necessary in Haskell anyway.

Yet I'm concerned it might not work as smoothly anymore when the objects are managed from garbage-collected Haskell, and I might need to come up with heuristics to migrate seldom-used objects back to host memory (which tends to be quite slow). Is this fear reasonable or is the GHC garbage collection so effective that most objects will vanish almost as quickly as in C++, even when the Haskell runtime doesn't see it needs to be economic on memory? Are there any tricks to help, or ways to signal that some objects take up too much GPU memory and should be removed as quickly as possible?

like image 264
leftaroundabout Avatar asked May 24 '12 11:05

leftaroundabout


People also ask

How long do garbage disposals last?

The life cycle of your garbage disposal is going to depend on how often it’s being used, whether or not it’s a modern model, or if it’s being properly maintained. Typically, you can expect your garbage disposal to last anywhere from 8-15 years.

How long do InSinkErator garbage disposals last?

For example, with proper maintenance and care, you can increase the lifespan of your garbage disposal to anywhere between 15-20 years. Wondering how long do InSinkErator garbage disposals last? Well, the lifespan of an InSinkErator garbage disposer is better than other brands; plus, they are backed with generous warranties.

What time should you put out your garbage?

During the summer, you can be fined for putting the garbage out before 5 p.m.; the rest of the year, it’s 4 p.m. While a local politician says the Dept. of Sanitation overstepped its bounds by enacting the policy without a public comment period, the bigger question is whether or not these guidelines are fair.

Do garbage disposals stop working after a while?

Garbage disposals are great for cleanup during food prep, getting rid of unwanted peels, expired food, or even unwanted leftovers. Almost daily, homeowners take advantage of the luxury a garbage disposer provides. That is until it stops working. If you’re in that boat, don’t worry.


1 Answers

even when the Haskell runtime doesn't see it needs to be economic on memory?

This is the issue: the GHC GC doesn't know how big your foreign objects are, so they don't exert any heap pressure, and thus aren't collected as soon as they could be.

You can mitigate this by calling performGC manually to force a major GC.

like image 50
Don Stewart Avatar answered Sep 21 '22 05:09

Don Stewart