On 7/13/06, Andrew Piskorski <[EMAIL PROTECTED]> wrote:
On Thu, Jul 13, 2006 at 08:44:17PM +0100, Stephen Deasey wrote:

> Byte code can only be cached per-interp and our caches are
> server-wide.  Currently, it's just caching the read of the Tcl source
> from disk.

I thought the way Rob Mayoff's original feature worked was that it
"compiled" *.tcl pages to Tcl procs, then cached the compiled bytecode
of those procs, presumably in per-thread caches.  Does that sound
right?


No.  Tcl code is compiled by running it.  It's is compiled on demand.

Except... Rob found a neat way to cheat by passing the script as an
arg to a do-nothing 'for' command.  'for' compiles the script for you.
Very smart and hellish to read...


What happens for ordinary Tcl procs in ordinary Naviserver Tcl
libraries?  When do they get compiled to bytecode, and how does
Naviserver avoid constantly recompiling them?


They're compiled when they're first called.

Remember, the naviserver threading model is to run Tcl interps in
different threads. This is the only way to do it as that's the only
promise of thread safety Tcl provides.

Everything else needs special treatment, hence the nsv_ interface
which communicates between interps.

So, if you have one virtual server defined, and 10 threads, each proc
will be compiled 10 times, one each for each interp run by a conn
thread. (and again for sched threads, jobs threads, etc.).

The byte code is reused after that of course, unless the string
representation of a proc changes, i.e. you redefine it.


Btw, is the byte code for a given Tcl snippet actually different
somehow for Tcl interps in different conn threads?


Yes.  The should be equal, but were compiled individually from
separate copies of the source.


> I think the way to go here is to merge Tcl pages in with the ADP page
> code.  What's the difference between an ADP page like this:

What would that accomplish?  Is there already cacheing of the
bytecodes of Tcl source included in ADP pages?


Yes.  And also, the bit below...


> The ADP stuff in aolserver 4.5 has *output* caching.  Tcl pages would

Huh?  Caching of the output generated by Tcl code is totally different
than cacheing the compiled Tcl bytecodes.  Both are useful, neither is
a replacement for the other.


Right, output caching is a different thing.  But wouldn't it be cool
to have it working for ADP pages, Tcl pages, registered procs etc.?

I don't want to implement that 3 separate times.

Reply via email to