[Kss-devel] Kupu kss plugin | overhead
Balazs Ree
ree at ree.hu
Sun Oct 5 08:51:45 CEST 2008
Hi Vladislav,
On Sun, 05 Oct 2008 03:42:41 +0200, Vladislav Vorobiev wrote:
> Hello, i write a kupu plugin for zope (without plone).
Is this code publicly available somewhere?
> My plugin works by now and Zope startup without problems. The matter is,
> if I request my plugin for a first time
> "http://localhost/mySiteWithKupuPlugin" zope makes overhead something
> like follows for 3 minutes.
>
> asks: 136 total, 1 running, 135 sleeping, 0 stopped, 0 zombie Cpu0
> :100.0%us, 0.0%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si,
> 0.0%st Cpu1 : 1.0%us, 0.0%sy, 0.0%ni, 98.7%id, 0.0%wa, 0.0%hi,
> 0.3%si, 0.0%st Mem: 1035848k total, 1008016k used, 27832k free,
> 26100k buffers Swap: 3927884k total, 92k used, 3927792k free,
> 471416k cached
>
> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 24350
> zope 20 0 81144 41m 3464 S 99 4.1 2:11.56 python2.4
>
> My files
>
> -rw-r--r-- 1 vavvav vavvav 549 2008-10-05 02:07 configure.zcml
> -rw-r--r-- 1 root root 0 2008-10-05 02:07 configure.zcml~
> -rw-r--r-- 1 vavvav vavvav 0 2008-10-05 01:54 __init__.py
> -rw-r--r-- 1 vavvav vavvav 38 2008-10-05 01:53
> ksstutorial-configure.zcml -rw-r--r-- 1 vavvav vavvav 110 2008-10-05
> 03:11 tutorial.kss -rw-r--r-- 1 vavvav vavvav 296412 2008-10-05 02:58
> tutorialplugin.js -rw-r--r-- 1 vavvav vavvav 25571 2008-10-05 03:16
> tutorial.pt
>
> My tutorialplugin.js file is very big because it includes all kupu(*).js
> libreries.
> It seems to be that zope analyze all this javascript code. Are there
> methods to turn of the analyzing, for example outsourcing the libereries
> in other file?
I don't understand this. I'm not aware of zope analizing any js code. Can
you please provide some more details?
> I only want to load the libraries dynamically if somebody
> requests kupu. Whats the standard method if I have to load big *.js
> static libreries?
There is no standard method. Most js library provide this, in various
different ways.
I myself, wrote an on-demand js loader, that works with kss (it uses the
RequestManager for the actual request). It works on all the browsers I
tried on. Basically, it accepts a set of javascript resources to load.
Loading is done in parallel, with the limitation of maximal requests
and timeout handling provided by kss natively.
When these are all loaded and evaluated, it calls the specified callback
where you can continue execution. If the resources are already present,
or have been included in the static headers, they are not loaded again.
For loading kss components (like, plugins) this may not work very well:
first it could actually make page load slower because the resources
loaded on demand are acquired much later during the page load, than in
the static way. Second, kss should be able to freeze its engine until
these resources are loaded and resume processing later from the callback;
this is currently not supported in the way that would be necessary
for this use.
However it can be a viable solution for loading thirdparty javascript
code like in your case. This is what I used it for: loading the jsMath
library, that is pretty big, from a kss action that needs it.
If the code is there the action executes immediately, if not, the
resource is loaded and the action continues after it became available.
In my use case delay caused by the load was no problem either, for the usage.
The code that does this is part of the kss.plugin.jsmath: please feel
free to copypaste it to your own code and experiment with it. In case
more people find it useful, it can go to a component on its own.
http://bazaar.launchpad.net/~kissbooth/kss.plugin.jsmath/trunk/annotate/21?file_id=kss_jsmath.js-20071127201149-79dx2pzwy2ftq08k-32
Best wishes,
--
Balazs Ree
More information about the Kss-devel
mailing list