Quantcast

"(Delay forSeconds: aSeconds) wait" consume 100% CPU of single thread

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

"(Delay forSeconds: aSeconds) wait" consume 100% CPU of single thread

sibendovi.w2
Hello,

I was wondering if there is way to run Delay>>wait with zero CPU usage to give better chances to other forked processes on machine to finish sooner. On Windows 7 virtual machine goes to 100% CPU usage of single thread during the #wait.

Thank you,

     Stan

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "(Delay forSeconds: aSeconds) wait" consume 100% CPU of single thread

Marten Feldtmann-4
There is no need to do this - actually with a Delay in the UI thread you force VA to poll the system.

Marten


Am Mittwoch, 26. April 2017 03:09:42 UTC+2 schrieb [hidden email]:
Hello,

I was wondering if there is way to run Delay>>wait with zero CPU usage to give better chances to other forked processes on machine to finish sooner. On Windows 7 virtual machine goes to 100% CPU usage of single thread during the #wait.

Thank you,

     Stan

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "(Delay forSeconds: aSeconds) wait" consume 100% CPU of single thread

Louis LaBrunda
In reply to this post by sibendovi.w2
Hi Stan,

Something seems odd here.  Delays should not use 100% CPU unless the computer/OS doesn't have the timer interrupt installed, see Delay class #preStartUp and #initializeTimerInterrupt.  In that case #wait will do a Processor yield and if you are looping on the wait, that can run up the CPU.  I don't know much about Windows 7 virtual machine but I would look there to see if/why timer interrupt isn't supported or needs to be turned on.  If you are in the development environment, you can inspect Delay installed, to see if the timer interrupt is installed.  If it isn't or can't be turned on, get back to us and we will see what else we can think of.

Lou

On Tuesday, April 25, 2017 at 9:09:42 PM UTC-4, [hidden email] wrote:
Hello,

I was wondering if there is way to run Delay>>wait with zero CPU usage to give better chances to other forked processes on machine to finish sooner. On Windows 7 virtual machine goes to 100% CPU usage of single thread during the #wait.

Thank you,

     Stan

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "(Delay forSeconds: aSeconds) wait" consume 100% CPU of single thread

Bob Brodd
In reply to this post by sibendovi.w2
Hi Stan

On Tuesday, April 25, 2017 at 9:09:42 PM UTC-4, [hidden email] wrote:
Hello,

I was wondering if there is way to run Delay>>wait with zero CPU usage to give better chances to other forked processes on machine to finish sooner. On Windows 7 virtual machine goes to 100% CPU usage of single thread during the #wait.

Thank you,

     Stan

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "(Delay forSeconds: aSeconds) wait" consume 100% CPU of single thread

Bob Brodd
In reply to this post by sibendovi.w2
Hi Stan,

You can try using AbtTimedWait instead of Delay.  It has a slightly different protocol from Delay; for example, a 5 second delay would be initiated by "AbtTimeWait forSeconds: 5" instead of "(Delay forSeconds: 5) wait".  It uses asynchronous callouts (if supported) and the OS Sleep function to accomplish the delay.

Bob  

On Tuesday, April 25, 2017 at 9:09:42 PM UTC-4, [hidden email] wrote:
Hello,

I was wondering if there is way to run Delay>>wait with zero CPU usage to give better chances to other forked processes on machine to finish sooner. On Windows 7 virtual machine goes to 100% CPU usage of single thread during the #wait.

Thank you,

     Stan

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "(Delay forSeconds: aSeconds) wait" consume 100% CPU of single thread

Marten Feldtmann-4
Doing a Delay in the UI thread makes VASmalltalk polling - consuming 100% CPU time. Using AbtTimedWait creates an asynchrouns call - but does actually NOTHING in the semantic meaning you expect.

The simple answer to your question is: do NOTHING ... and leave your VASmalltalk alone and then the background processes will get maximum performance. If you move your application windows around, make a resize or anything else in your UI and the UI thread will have to do work (and your background process will loose CPU cycles).

Perhaps an alternative is to create background processes with ultra-high priority - but that may introduce other problems.

Marten

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "(Delay forSeconds: aSeconds) wait" consume 100% CPU of single thread

sibendovi.w2
Hi Marten,

I am forking Windows operating system process, and would like to wait for it to finish by periodically checking if its output file exists. It would be cleaner if VA would not consume 100% CPU of one core, to give more resources to that forked process. It is not big problem. I was just curious if I am not missing some simple settings.

Have a nice day,

      Stan

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "(Delay forSeconds: aSeconds) wait" consume 100% CPU of single thread

Marten Feldtmann-4
Then the solution is simple:

* create a Smalltalk green process (background) and do the work in this Smalltalk green process.

* if the Smalltalk green process has found the state you are waiting for you may signal the UI about that

Marten

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "(Delay forSeconds: aSeconds) wait" consume 100% CPU of single thread

sibendovi.w2
In reply to this post by Bob Brodd
Hi Bob,

Thank you for suggestion. AbtTimedWait is indeed idling CPU. However, it keeps UI active, and breaks Debugger while stepping over it on "Primitive failed in: Process>>#stackAtFrame:offset: due to Process dead in receiver".
One could not have everything :-).

Have a nice day,

      Stan

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "(Delay forSeconds: aSeconds) wait" consume 100% CPU of single thread

sibendovi.w2
In reply to this post by Marten Feldtmann-4
Hi Marten,

I am proceeding with ordinary Delay>>wait to not increase complexity and cost of maintenance of the code. Slightly higher CPU usage is small price for single threaded debugging.

Thank you all for valuable information,

       Stan

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Loading...