Categories > TinyButStrong general >

Why does tiny kill my server?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Adam Horvath
Date: 2006-06-22
Time: 13:19

Why does tiny kill my server?

Hi!

Can you help me? It's really important for me to keep on.
The boss is impatient. :)

It does a big-big CPU load, and a lot of time.

Why? What can I do wrong?

Php side:

$rCT = range(1, 100);
$tbs->MergeBlock("rCT", $rCT);

And the template:

<table>
  <tr>
     <td>[var.AZON[rCT.val;block=table]_t]</td>
     <td>[var.AZON[rCT.$]_v]</td>
  </tr>
  <tr>
    <td>[var.ROV[rCT.$]_t]</td>
    <td>[var.ROV[rCT.$]_v]</td>
  </tr>
  ...
  up to twenty or more
</table>

The result should be:
hundred table like this:
<table>
  <tr>
    <td>value of AZON1_t</td>
    <td>value of AZON1_v</td>
  </tr>
  ...
</table>
<table>
  <tr>
    <td>value of AZON2_t</td>
    <td>value of AZON2_v</td>
  </tr>
  ...
</table>
...
By: Adam Horvath
Date: 2006-06-22
Time: 13:54

Re: Why does tiny kill my server?

so, the script is working the result html source is perfect.

But to load the page is half a minute and
the httpd process CPU usage is from 1% to 10% or more at the end of the request. (sun enterprise 3500 server)

Is it some recursion or tiny bug or syntax error?

Very mysterious.
By: Skrol29
Date: 2006-06-23
Time: 11:23

Re: Why does tiny kill my server?

You snippet show 2.000 global variable in a page. This is big but not so enormous. It shoudn't be that long.
I'll make some benches with your case, and I'll alos try other way to do the same. But I'm sorry I won't be able to give suggestions before several hours.

What data are you displaying? (long strings?)
By: Skrol29
Date: 2006-06-23
Time: 15:37

Re: Why does tiny kill my server?

Hi Adam,

I've tested your snippet which merges 5200 global variables using a block with 26 rows and 2 columns. This block is marged with 100 records (100x26x2=5200).
On my PC it takes 1min 10sec, this is pretty long.

I've tryied the following snippet which does the same in 1 sec.
The idea is to use the block to directly merge the data, because MergeBlock() can cache block's sections and block's tags.
PHP side:
$tbs->MergeBlock('rCT','num',100); // Merges numbers from 1 to 100

// Ondata function used in the template
function f_ondata_feed($BlockName,&$CurrRec,$RecNum) {
  global $TypeNames; // contains keywords OZON, ROV, ...
  foreach ($TypeNames as $x) {
    $CurrRec[$x.'_t'] =& $GLOBALS[$x.$CurrRec['val'].'_t'] ;
    $CurrRec[$x.'_v'] =& $GLOBALS[$x.$CurrRec['val'].'_v'] ;
  }
}


HTML side:
<table>
  <tr>
     <td>[rCT.AZON_t;block=table;ondata=f_ondata_feed]</td>
     <td>[rCT.AZON_v]</td>
  </tr>
  <tr>
    <td>[rCT.ROV_t]</td>
    <td>[rCT.ROV_v]</td>
  </tr>
  ...
  26 like this. Keywords AZON, ROV, ... are stored into $TypeNames
</table>