GC and valueUninterruptably

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

GC and valueUninterruptably

Vincent Lesbros-2
Hi !

I have to run some critical code, and prevent any interruption by the GC during the time of the process.
about preventing the GC to run.

My process is calling a C function that callback a Smalltalk block every 0.00853333 second.
This is working well, until the GC runs.
If I protect the call with [ .... the main call ] valueUninterruptably 
I have effectively no interruptions while the process is running.
BUT : I have to give the user a way to stop this process at any time.

If I give the user an opportunity to stop, 
I give at same time an opportunity to the garbage collector to interrupt the process.

How can I give to the callback block a priority against the GC, without being preemptive for user control ?

Thanks for any suggestion.

Vincent



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: GC and valueUninterruptably

Paul Baumann

Funny, normally you want to allow cleanup operations to happen while they can. I believe that recent version of the VW VM have a way to suspend GC operations so that GemTalk’s GBS product can prevent objects from being finalized from weak collections during a callout to GS. Someone else can probably respond with a pointer to that code (or perhaps an undocumented primitive).

 

If somehow the callback block is being GC’ed during the callout then look for a way to strongly reference the callback block during the callout. It is easy to overuse #valueUninterruptably . Consider using a semaphore instead of something as severe as #valueUninterruptably. If you must use #valueUninterruptably then keep it to small changes without instance creation. #valueUninterruptably can be preempted by higher priority processes; therefore, a way to prevent a high priority GC operation is to temporarily bump up the priority of the active process. It may give you what you are asking for, but disabling GC can have more severe consequences. If the GC you are trying to avoid is non-critical then you can tune the GC policy or use #quickGC before your critical areas.

 

Paul Baumann

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Vincent Lesbros
Sent: Friday, May 31, 2013 12:05
To: [hidden email]
Subject: [vwnc] GC and valueUninterruptably

 

Hi !

 

I have to run some critical code, and prevent any interruption by the GC during the time of the process.

about preventing the GC to run.

 

My process is calling a C function that callback a Smalltalk block every 0.00853333 second.

This is working well, until the GC runs.

If I protect the call with [ .... the main call ] valueUninterruptably 

I have effectively no interruptions while the process is running.

BUT : I have to give the user a way to stop this process at any time.

 

If I give the user an opportunity to stop, 

I give at same time an opportunity to the garbage collector to interrupt the process.

 

How can I give to the callback block a priority against the GC, without being preemptive for user control ?

 

Thanks for any suggestion.

 

Vincent

 

 



This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: GC and valueUninterruptably

Andres Valloud-6
In reply to this post by Vincent Lesbros-2
Look at the memory policy classes like LargeGrainMemoryPolicy (keep in
mind that MemoryPolicy is obsolete).  Those are the ones that call for
the GC to act.  Likely you will want to make a subclass and refine e.g.
how the memory policy decides to GC or to grow memory when there's a low
space situation.  If you're concerned about the IGC, you may want to
look at allowIncGC: in later versions.  Moreover, you will have to look
at all senders of messages such as ObjectMemory quickGC, or
garbageCollect, and the like.  The memory policy is not the only object
capable of asking the VM to GC.

Finally, all this is fine except it won't stop the VM from scavenging
new space, which is also a form of GC.  What exactly is the reason why
you don't want GC to occur?

On 5/31/13 9:05 AM, Vincent Lesbros wrote:

> Hi !
>
> I have to run some critical code, and prevent any interruption by the GC
> during the time of the process.
> Looking in the archive I found
> http://www.parcplace.net/list/vwnc-archive/0604/msg00070.html
> about preventing the GC to run.
>
> My process is calling a C function that callback a Smalltalk block
> every 0.00853333 second.
> This is working well, until the GC runs.
> If I protect the call with [ .... the main call ] valueUninterruptably
> I have effectively no interruptions while the process is running.
> BUT : I have to give the user a way to stop this process at any time.
>
> If I give the user an opportunity to stop,
> I give at same time an opportunity to the garbage collector to interrupt
> the process.
>
> How can I give to the callback block a priority against the GC, without
> being preemptive for user control ?
>
> Thanks for any suggestion.
>
> Vincent
>
>
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: GC and valueUninterruptably

mkobetic
In reply to this post by Vincent Lesbros-2
I think you're looking for #valueUnpreemptively. Note and heed however the very serious warning in that method, you have to be extremely careful about what you do in an unpreemptive block, it should be as little as you possibly can get away with.

The #valueUninterruptably protects against interruptions via the #interruptWith: message, it doesn't prevent normal pre-emption.

HTH,

Martin

"Vincent Lesbros"<[hidden email]> wrote:

> Date: May 31, 2013 12:05:20 PM
> From: Vincent Lesbros <[hidden email]>
> To: [hidden email]
> Subject: [vwnc] GC and valueUninterruptably
>
> Hi !
>
> I have to run some critical code, and prevent any interruption by the GC
> during the time of the process.
> Looking in the archive I found
> http://www.parcplace.net/list/vwnc-archive/0604/msg00070.html
> about preventing the GC to run.
>
> My process is calling a C function that callback a Smalltalk block
> every 0.00853333 second.
> This is working well, until the GC runs.
> If I protect the call with [ .... the main call ] valueUninterruptably
> I have effectively no interruptions while the process is running.
> BUT : I have to give the user a way to stop this process at any time.
>
> If I give the user an opportunity to stop,
> I give at same time an opportunity to the garbage collector to interrupt
> the process.
>
> How can I give to the callback block a priority against the GC, without
> being preemptive for user control ?
>
> Thanks for any suggestion.
>
> Vincent
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc