Forum OpenACS Q&A: large procs and speed

Collapse
Posted by David Kuczek on
Similar to the footer and header proc we have a left side navigation
proc which holds several procs returning i.e. "users online", "admin
links", "current events" etc.

The regular acs-pages appear to be quite quicker than the pages with
our left side navigation.

Is there any design standards we don't know of, that don't recommend
to do, what we did?

Collapse
Posted by Jonathan Ellis on
Well, if your navigation proc is running db queries, of course it's going to slow the page down more than a simple "here, use this style sheet" sort of proc.

Depending on what it is generating, you could try caching parts or all of it.  But it shouldn't be surprising that as you make your server do more, it will take longer.

Collapse
Posted by David Kuczek on
My question was not very detailled... I actually wanted to know, whether the same amount of database queries are executed slower when using procs and subprocs and subsubprocs etc. instead of having those queries directly and only on the relevant .tcl page that is seen by the user.
Thanks.
Collapse
Posted by Michael A. Cleverly on
With nsd7x probably not much of a difference speed wise.  With nsd8x and Tcl 8 bytecode compilation, it's my understanding from past threads on the AOLserver mailing list that one reason Kriston (of AOL) recommended against .tcl files under the page root is that nsd8x does not retain the compiled byte-code version like it does with .adp's and with the private and shared Tcl libraries.  So you'd have a (slight?) gain from having procs in your servers Tcl library since they wouldn't have to be re-byte-code compiled each time they were accessed.

I'd suggest you structure your code so that it's clear and easy for you (and others you work with) to understand, maintain, and extend.  CPU cycles are cheap in comparisons to peoples time.

Collapse
Posted by Patrick McNeill on
Michael, several months ago Rob Mayoff and I (well, a lot of Rob and a little of me:)) rewrote parts of the file serving system in AOLServer such that it will cache Tcl pages if you have the ns_cache module loaded.  I don't know if this is in the AOLServer or OpenNSD distros, but it is in the more recent ArsDigita distribution and in our CVS tree.  The modifications are in file.tcl and tclcache.tcl, in the nsd/tcl directory.  Essentially, if the ns_cache module is available, the new code will cache the bytecode of the page and a signature of the file (last modified, size, etc) to determine if it has changed.  If you have a lot of Tcl pages, it's likely that some will be evicted from the cache.  However, files that are commonly hit won't be since it's LRU.