Words:  

Re: Cpu usage of stored procedures

Date: 08-02-10
From: Kevin LaTona <4dlist_at_studiosola.com>

Paul,

On Feb 8, 2010, at 1:17 AM, Bryan Green wrote:
> On Feb 7, 2010, at 11:15 PM, psmith wrote:
>
>> On a "client" machine it is very fast, creating about 300 records a
>> second or more. On the server side, the same method only creates
>> about 8 or 10 records a second, making it at least 30 times slower
>> than the same method running on a client machine.
> Try calling FLUSH BUFFERS every 10 SAVE RECORDS or so. The slowdown
> sounds like the cache is becoming full, which "shouldn't" be slow
> but perhaps is. The FLUSH BUFFERS will mitigate that.


Bryan could be on to something here.

I've just started looking at 4D's get cache call, I believe there is a
Tech Note on it some where at 4D.


Below is a beta method I wrote several weeks back but haven't put into
full play.

Take a peek and tweak it as needed maybe it will help you track your
cache to get a better idea what might be going on with the server.

Don't forget to post any improvements to the below method if you end
up using it.


-Kevin






`(PM) logCacheController
`reads the 4D cache command and dumps it into a tab delimited text
line that is written to a disk file at the db folder level
`this method is self starting and can be called either from a menu
bar call or by creating a start and stop calling method.
`the time between reads can be adjusted to what is needed or prefered
`the get cache stat call currently grabs all avaliable 4D data
points, certainly not all are needed depending.
`data could be sent to ms excel or could do a svg graph someday

C_BOOLEAN(◊stopCacheLogger)
C_TEXT($cacheLogPath)
C_TEXT($msg;$1)
C_LONGINT($delayBetweenInSeconds)
`--

$delayBetweenInSeconds:=15
`--

If (Count parameters=0) `a menu bar request is coming in
$menuTitle:=Get menu title(Menu selected\65536)
$menuItem:=Get menu item(Menu selected\65536;Menu selected%65536)
$msg:=$menuItem
Else `passing a message style request here
$msg:=$1
End if
`--


Case of
: ($msg="logCacheStart") `start up by creating a new process for
this to run in

◊stopCacheLogger:=False

$procNum:=New Process("logCacheController";
1024*64;"logCacheController";"run";*)
`--

: ($msg="run") `do the log here

$cacheLogPath:=Get 4D folder(Database Folder )+"cacheLog.txt" `get
active db folder path+ add doc's name
`--

$stopTime:=Current time+$delayBetweenInSeconds `set 1st timeout
before going into the loops
`--


Repeat `outter loop


Repeat `inner process delay loop
DELAY PROCESS(Current process;10)
Until (Current time>$stopTime)
`--

$stopTime:=$stopTime+$delayBetweenInSeconds `reset counter now may
need to tweak this number based on below work that needs to be done
`--

ARRAY TEXT(cacheNames;0)
ARRAY REAL(cacheValues;0)
ARRAY REAL(cacheCount;0)
GET CACHE STATISTICS(1+2;cacheNames;cacheValues;cacheCount)
`--

$data2Write:="" `clear line var
$data2Write:=String(Current time)+Char(Tab ) `add time stamp

$i:=0
For ($i;1;Size of array(cacheNames)) `build the cache values line
items here
$data2Write:=$data2Write+String(cacheValues{$i})+Char(Tab )
End for
`--

$data2Write:=$data2Write+Char(Carriage return ) `add end of record
control character now
`--


If (Test path name($cacheLogPath)#Is a document ) `make sure no
one dumped the log doc

$dataHeader:=""
$dataHeader:="timeStamp"+Char(Tab )
For ($ii;1;Size of array(cacheNames)) `since this is a new doc
add the 1st row that shows what these hearers are
$dataHeader:=$dataHeader+cacheNames{$ii}+Char(Tab )
End for
`--

$dataHeader:=$dataHeader+Char(Carriage return )
`--

$docRef:=Create document($cacheLogPath)
SEND PACKET($docRef;$dataHeader)
SEND PACKET($docRef;$data2Write)
CLOSE DOCUMENT($docRef)
SET DOCUMENT CREATOR($cacheLogPath;"TEXT")
`--

Else `go ahead and append data into exisiting log doc

$docRef:=Append document($cacheLogPath)
SEND PACKET($docRef;$data2Write)
CLOSE DOCUMENT($docRef)
`--
End if
`--

Until (◊stopCacheLogger#False)
`--


: ($msg="logCacheStop") `stop the log process

◊stopCacheLogger:=True
`--

End case

`----


`eom

**********************************************************************
The New 4D Partner Program - All the tools you need to be a successful 4D Developer.
Sign up Now: http://www.4d.com/community/partner/registration.html


4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe_at_lists.4D.com
**********************************************************************