VM freezes; how to find the cause?

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

Re: VM freezes; how to find the cause?

jtuchel
Hi Bahman,

Smalltalk has a very similar thread model to the one of Java. You can
start threads/Processes with priorities and therefor the behavior is
very much like the one you describe. A web server (in Pharo you'd use
Zn, I guess) kicks off worker threads at a certain priority to fulfill
web requests and thus they are independent from each other. If one eats
up cpu cycles, it will still yield to other processes because the
Scheduler will switch processes from time to time. The GUI thread has
quite some high Priority (at least in the environments I know a bit
better) and therefor can make the image unresponsive (frozen).

So in the end it is up to you (or the frameworks you use, like
Seaside/Zn) to take care of this situation. Very much like in Java.

Joachim



Am 28.05.13 05:32, schrieb Bahman Movaqar:

> On 2013-05-27 22:29, intrader wrote:
>> As you now know, it is very simple to inadvertently cause your code to
>> freeze. I have managed to get my code to freeze in various ways including
>> recursion caused by initialize.AND, test before you deploy in a production
>> environment.
>>
>> The VM is correctly doing what you tell it to do.
> That's right.
>
> My only question is that, should a single bad process freeze the whole
> image?
>
> A process can go CPU-wild not only during initialisation but also by I/O
> block/deadlock, e.g. when accessing the database.  I know, it is not
> usual or something that happens on a daily basis.
>
> I've had this on JVM: running multiple applications on a web server.
> Out there if the freeze happened at web server level, well, all
> applications were down and out of reach.  However if the freeze happened
> in application (my code) level, the CPU usage would increase -sometimes
> to 100%- but the other web applications would remain accessible though slow.
>
> I'm wondering about a way to achieve the same behaviour on Smalltalk.
>

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: VM freezes; how to find the cause?

bahman
On 2013-05-28 08:46, Joachim Tuchel wrote:
Hi Bahman,

Smalltalk has a very similar thread model to the one of Java. You can start threads/Processes with priorities and therefor the behavior is very much like the one you describe. A web server (in Pharo you'd use Zn, I guess) kicks off worker threads at a certain priority to fulfill web requests and thus they are independent from each other. If one eats up cpu cycles, it will still yield to other processes because the Scheduler will switch processes from time to time. The GUI thread has quite some high Priority (at least in the environments I know a bit better) and therefor can make the image unresponsive (frozen).

So in the end it is up to you (or the frameworks you use, like Seaside/Zn) to take care of this situation. Very much like in Java.


What you're basically saying is that
  1.  Web application is a thread: if it blocks it only blocks its own thread meaning other web applications will still be accessible. 
  2.  Web server is a thread: if it blocks all web applications will be blocked but the VM is still accessible.
If that's true, well, it adds to my confusion :-)  The -possible- bad initialisation occurred in a web application and in worst case at the web server level.  Then why did the VM became non-operational?  According to what you say, only the web application or in worst case "Zn" must have become frozen.

I'm just trying to understand the process model Seaside is based on.




Am 28.05.13 05:32, schrieb Bahman Movaqar:
On 2013-05-27 22:29, intrader wrote:
As you now know, it is very simple to inadvertently cause your code to
freeze. I have managed to get my code to freeze in various ways including
recursion caused by initialize.AND, test before you deploy in a production
environment.

The VM is correctly doing what you tell it to do.
That's right.

My only question is that, should a single bad process freeze the whole
image?

A process can go CPU-wild not only during initialisation but also by I/O
block/deadlock, e.g. when accessing the database.  I know, it is not
usual or something that happens on a daily basis.

I've had this on JVM: running multiple applications on a web server.
Out there if the freeze happened at web server level, well, all
applications were down and out of reach.  However if the freeze happened
in application (my code) level, the CPU usage would increase -sometimes
to 100%- but the other web applications would remain accessible though slow.

I'm wondering about a way to achieve the same behaviour on Smalltalk.



Thank you,
-- 
Bahman Movaqar  (http://BahmanM.com)
ERP Evaluation, Implementation, Deployment Consultant

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: VM freezes; how to find the cause?

jtuchel
Hi again,

Am 28.05.13 06:51, schrieb Bahman Movaqar:

I'm going to answer based on my (basic) knowledge of VA Smalltalk's implementation in its Server Smalltalk feature, which I guess is quite similar to what Zn in Pharo offers.
What you're basically saying is that
  1.  Web application is a thread: if it blocks it only blocks its own thread meaning other web applications will still be accessible. 

Well, in fact each http request gets answered in its own thread, so in the best of cases, only one single http request is blocked. You can still work on other requests and talk to the same application in other sessions. Imagine a ServerAdaptor in your smalltalk image kicking of an ST thread for each incoming request.
  2.  Web server is a thread: if it blocks all web applications will be blocked but the VM is still accessible.
Well, yes. The web server (which is really just a small listener on a socket) is a Thread in your Smalltalk Image. If it blocks, the VM cannot answer any http requests any more. In a development image, you can still work with Smalltalk Browsers and dev tools, because they run in another thread.

If that's true, well, it adds to my confusion :-)  The -possible- bad initialisation occurred in a web application and in worst case at the web server level.  Then why did the VM became non-operational?  According to what you say, only the web application or in worst case "Zn" must have become frozen.
In theory, that is what happened. Just like in any other multithreading environment, there are lots of things that can happen when you make little mistakes. If you start a process with such a high priority that it won't let ohers execute any more.
Then, there are exceptions to the things mentioned. External calls, for example, can block the whole VM (depending on how you call out of the image), even if they are issued in a low priority background process.  You can produce deadlocks with Semaphores and stuff. Lots of things can go wrong in multithreaded environments.

Joachim

I'm just trying to understand the process model Seaside is based on.




Am 28.05.13 05:32, schrieb Bahman Movaqar:
On 2013-05-27 22:29, intrader wrote:
As you now know, it is very simple to inadvertently cause your code to
freeze. I have managed to get my code to freeze in various ways including
recursion caused by initialize.AND, test before you deploy in a production
environment.

The VM is correctly doing what you tell it to do.
That's right.

My only question is that, should a single bad process freeze the whole
image?

A process can go CPU-wild not only during initialisation but also by I/O
block/deadlock, e.g. when accessing the database.  I know, it is not
usual or something that happens on a daily basis.

I've had this on JVM: running multiple applications on a web server.
Out there if the freeze happened at web server level, well, all
applications were down and out of reach.  However if the freeze happened
in application (my code) level, the CPU usage would increase -sometimes
to 100%- but the other web applications would remain accessible though slow.

I'm wondering about a way to achieve the same behaviour on Smalltalk.



Thank you,
-- 
Bahman Movaqar  (http://BahmanM.com)
ERP Evaluation, Implementation, Deployment Consultant


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: VM freezes; how to find the cause?

bahman
On 2013-05-28 09:51, Joachim Tuchel wrote:

> Hi again,
>
> Am 28.05.13 06:51, schrieb Bahman Movaqar:
>
> I'm going to answer based on my (basic) knowledge of VA Smalltalk's
> implementation in its Server Smalltalk feature, which I guess is quite
> similar to what Zn in Pharo offers.
>> What you're basically saying is that
>>   1.  Web application is a thread: if it blocks it only blocks its
>> own thread meaning other web applications will still be accessible.
>
> Well, in fact each http request gets answered in its own thread, so in
> the best of cases, only one single http request is blocked. You can
> still work on other requests and talk to the same application in other
> sessions. Imagine a ServerAdaptor in your smalltalk image kicking of
> an ST thread for each incoming request.
>>   2.  Web server is a thread: if it blocks all web applications will
>> be blocked but the VM is still accessible.
> Well, yes. The web server (which is really just a small listener on a
> socket) is a Thread in your Smalltalk Image. If it blocks, the VM
> cannot answer any http requests any more. In a development image, you
> can still work with Smalltalk Browsers and dev tools, because they run
> in another thread.
>
>> If that's true, well, it adds to my confusion :-)  The -possible- bad
>> initialisation occurred in a web application and in worst case at the
>> web server level.  Then why did the VM became non-operational?
>> According to what you say, only the web application or in worst case
>> "Zn" must have become frozen.
> In theory, that is what happened. Just like in any other
> multithreading environment, there are lots of things that can happen
> when you make little mistakes. If you start a process with such a high
> priority that it won't let ohers execute any more.
> Then, there are exceptions to the things mentioned. External calls,
> for example, can block the whole VM (depending on how you call out of
> the image), even if they are issued in a low priority background
> process.  You can produce deadlocks with Semaphores and stuff. Lots of
> things can go wrong in multithreaded environments.
>
> Joachim
>>
>> I'm just trying to understand the process model Seaside is based on.

@Joachim:  Thanks for the thorough explanation.  I'm still a tad bit
confused but I guess pushing this any further without me having a
containedly flawed code doesn't help :-)

Thank you all for your time.

--
Bahman Movaqar  (http://BahmanM.com)
ERP Evaluation, Implementation, Deployment Consultant

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
12