Re: ### Allocation failure

David Hakim <dhakim-Gkm/TONP9n1Wk0Htik3J/[email protected]> Tue, 15 Apr 2003 21:45:07 -0400
Newsgroups gmane.comp.lang.moto.devel
Message-ID <[email protected]>
Interesting, I'm pretty confident this is Sessions building up. I 
replicated the allocation failure with sessions enabled no problem 
(yep, right around 6-7K transactions/sessions 32M is used up) , however 
as soon as I disabled them I was able to run the ab test without 
incident. Please post the relevant portions of your httpd.conf. Here 
are mine for the compiled module on my httpd.conf (running on a g4 
portable 500Mhz Mac OS 10.2.5 with lots-o-other-things running :) )

=====httpd.conf====
LoadModule hello_module libexec/httpd/mod_hello.so

<IfModule mod_hello.c>
    <Location /hello>
       HelloOption Location /hello
       SetHandler hello
       HelloOption Session.Disable TRUE
    </Location>
</IfModule>
=================

And here was my ab output:

=================
% ab -t 0 'http://localhost/hello/hello.moto'
This is ApacheBench, Version 1.3d <$Revision: 1.1.1.9 $> apache-1.3
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, 
http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, 
http://www.apache.org/

Benchmarking localhost (be patient)
Completed 5000 requests
Completed 10000 requests
Completed 15000 requests
Completed 20000 requests
Completed 25000 requests
Completed 30000 requests
Completed 35000 requests
Completed 40000 requests
Completed 45000 requests
Finished 50000 requests
Server Software:        Apache/1.3.27
Server Hostname:        localhost
Server Port:            80

Document Path:          /hello/hello.moto
Document Length:        198 bytes

Concurrency Level:      1
Time taken for tests:   249.111 seconds
Complete requests:      50000
Failed requests:        0
Broken pipe errors:     0
Total transferred:      16550000 bytes
HTML transferred:       9900000 bytes
Requests per second:    200.71 [#/sec] (mean)
Time per request:       4.98 [ms] (mean)
Time per request:       4.98 [ms] (mean, across all concurrent requests)
Transfer rate:          66.44 [Kbytes/sec] received

Connnection Times (ms)
               min  mean[+/-sd] median   max
Connect:        0     1    NaN      0 56638
Processing:     2     3    7.7      2   800
Waiting:        0     2    7.1      2   800
Total:          2     4    NaN      2 56641

Percentage of the requests served within a certain time (ms)
   50%      2
   66%      2
   75%      3
   80%      3
   90%      3
   95%      6
   98%      7
   99%     19
  100%  56641 (last request)

Also, consider adding this script somewhere on your server so you can 
watch moto's memory, sessions and other persistent objects while 
benchmarking:

$use("codex.util")
$use("codex.http")

<html>
    <body bgcolor="#FFFFFF">
       <table border=0 cellpadding=0>
          <tr>
             <td valign=top>
                Total Memory = $(getTotalMemory() / (1024*1024 ))M
                             = $(getTotalMemory() / (1024 ))K
                             = $(getTotalMemory())B <br>
                Free Memory = $(getFreeMemory() / (1024*1024 ))M
                            =  $(getFreeMemory() / (1024 ))K
                            =  $(getFreeMemory())B <br>
                Used Memory = $((getTotalMemory()-getFreeMemory()) / 
(1024*1024 ))M
                            = $((getTotalMemory()-getFreeMemory()) / 
(1024 ))K
                            = $((getTotalMemory()-getFreeMemory()))B<br>
                Objects Allocated = $(getANodes()) <br>
                Available Segments = $(getFNodes()) <br>
                Total Context Objects = $(getContext().getObjectCount()) 
<br>
                Total Sessions = $(getContext().getSessionCount()) <br>
                States Per Session = 
$(getContext().getStatesPerSession()) <br>
                Session Timeout = $(getContext().getSessionTimeout()) 
<br>
             </td><td
                   height="100"
                   width="50"
                   bgcolor="0000FF"
                   valign=bottom
                  ><img
                   border="0"
                   src="rbar.gif"
                   width="50"
                   height="$(100 - 
<int>((<float>getFreeMemory()/getTotalMemory())*100))"
             ></td>
          <tr>
       </table>
    </body>
=================

-Dave

On Tuesday, April 15, 2003, at 11:45  AM, Scott Rogers wrote:

> Dave,
>
> I did as you asked.  I turned off sessions for the compiled 
> application and
> received the same result on the FreeBSD box.  FYI I also modified
> codex/sharedmem.h to execute the 'debug()' function when the error 
> occurs. So
> I have a 15mg httd error log with the tree dumps.  I don't understand 
> how to
> interperet the output however.
>
> I ran the app from the command line and received the following output:
>
> === BEGIN output ===
>> /usr/local/moto/bin/moto -d hello.moto
> /* */
>
>
>
> <html>
> <head>
> <style type="text/css">
>       </style>
>    </head>
>    <body>
>
> <hr>
>
> Hello&nbsp;bob&nbsp;<br/>
> Hello&nbsp;bobie&nbsp;
> <hr/>
>
>
>
> Title: Loud People Out Front
>
>
> <hr>
>    </body>
> </html>
>
> ---------------------------------------------------------
> Size Range Tree :
>  |[0x28165000,0x2a165000)| = 33554432 id=12 pid=712816190
> Allocated Range Tree :
> According to lo-mem we have 1 nodes allocated
> === END output ===
>
> On Tuesday 15 April 2003 05:21 pm, David Hakim wrote:
>> Interesting ... I'm really surprised that this failure is occurring
>> with the compiled module.
>>
>> Anyhow ... its pretty clear then that there is a memory leak at least
>> somewhere. Since your test page isn't really using codex.http, could
>> you run
>>
>> moto -d <test file>
>>
>> from the command line and verify that there are no leaks there ?
>>
>> Second, could you add the following directives to your httpd.conf:
>>
>> MotoOption Session.Disable TRUE
>>
>> changing the above to
>>
>> <CompiledModule>Option Session.Disable TRUE
>>
>> for your compiled module and re-run the ab tests ?
>>
>> -Dave
>>
>> On Tuesday, April 15, 2003, at 09:06  AM, Scott Rogers wrote:
>>> David,
>>>
>>> I experienced the same behavior on the FreeBSD box in interperted and
>>> compiled
>>> mode.  I did not try interperted on the Linux box.
>>>
>>> I did nothing to turn off sessions.  So, if sessions are on 'out of
>>> the box'
>>> then they were on for these tests.
>>>
>>> Scott Rogers
>>>
>>> On Tuesday 15 April 2003 03:50 pm, David Hakim wrote:
>>>> Is this under the interpreter or with a module compiled with mmc ?
>>>> Also, are sessions turned off for this application ?
>>>>
>>>> -Dave
>>>>
>>>> On Tuesday, April 15, 2003, at 07:03  AM, Scott Rogers wrote:
>>>>> Hey All,
>>>>>
>>>>> I recently did some performance testing of Moto on both FreeBSD 
>>>>> 4.6.2
>>>>> and
>>>>> Redhat Linux 7.2.
>>>>>
>>>>> FreeBSD
>>>>> Apache: 1.3.26
>>>>> Moto: 0.19.0
>>>>> 256mg ram
>>>>>
>>>>>
>>>>> RedHat
>>>>> Apache 1.3.27
>>>>> Moto: 0.19.0
>>>>> 1gig ram
>>>>>
>>>>> Using ApacheBench (ab with source distributions) in the following
>>>>> manner:
>>>>> ab -t 0 http://localhost/tmoto1/hello.moto
>>>>>
>>>>> This sends 50,000 connections to the server, one at a time.
>>>>> Somewhere
>>>>> between
>>>>> 5000 and 10,000 connections, Moto starts sending "### Allocation
>>>>> failure"
>>>>> messages to the Apache error log file.
>>>>>
>>>>> I tracked this down to line 568 of src/codex/sharedmem.c.  It seems
>>>>> there is
>>>>> not enough contiguous memory, according to function "locateLPFNode"
>>>>> at
>>>>> line
>>>>> #516.
>>>>>
>>>>> It seems when Moto is unable to return a large enough block of 
>>>>> memory
>>>>> from
>>>>> it's internal stack, it issues the above warning/error message to
>>>>> stderr.
>>>>>
>>>>> The problem is, it logs the message so many times it fills up my 
>>>>> /var
>>>>> file
>>>>> system in a matter of seconds!
>>>>>
>>>>> Also, it is important to note, that on the FreeBSD system Moto
>>>>> consumes all
>>>>> available RAM, but not on the Linux box with 1gig of Ram.
>>>>>
>>>>>
>>>>>
>>>>> Here is the code excerpt:
>>>>>
>>>>> === BEGIN hello.moto ===
>>>>> $use("codex.http")
>>>>> #include("my_classes.moto")
>>>>>
>>>>>
>>>>> <html>
>>>>> <head>
>>>>> <style type="text/css">
>>>>>       </style>
>>>>>    </head>
>>>>>    <body>
>>>>>
>>>>> <hr>
>>>>> ${
>>>>> HelloWorld hw = new HelloWorld();
>>>>> String message = hw.sayHelloTo("bob");
>>>>> }$
>>>>> $(message + "<br/>")
>>>>> $(hw.sayHelloTo("bobie"))
>>>>> <hr/>
>>>>>
>>>>> ${
>>>>> Box box = new Box("Loud People Out Front");
>>>>> }$
>>>>>
>>>>> $(box.renderStandard())
>>>>>
>>>>>
>>>>> <hr>
>>>>>    </body>
>>>>> </html>
>>>>> === END hello.moto ===
>>>>>
>>>>>
>>>>> === BEGIN my_classes.moto ===
>>>>> ${
>>>>>    class HelloWorld {
>>>>>       String sayHelloTo(String name){
>>>>>         return "Hello&nbsp;" + name + "&nbsp;";
>>>>>          }
>>>>>       }
>>>>>
>>>>>
>>>>>    class Box {
>>>>>      boolean _initalized = false;
>>>>>      String _title = "";
>>>>>
>>>>>       Box(String title) {
>>>>>        this._title = title;
>>>>>      }
>>>>>
>>>>>      String renderStandard() {
>>>>>        return "Title: " + _title;
>>>>>      }
>>>>>    }
>>>>>
>>>>> }$
>>>>> === END my_classes.moto ===
>>>>>
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Scott Rogers
>
>