You are viewing a plain text version of this content. The canonical link for it is here.
Posted to asp@perl.apache.org by Csongor Fagyal <co...@conceptonline.hu> on 2003/02/21 16:02:41 UTC

Response->Include

Hi,

If I understand correctly, <!--#include file="aspfile" 
args=@args-->compiles aspfile only once, and consequtive calls only pass 
@args to the precompiled script. I guess the same is done when I use 
$Response->Include($filename, @args). But what happens if I use 
$Response->Include(\$script_text, @args)? Is $srcipt_text recomplied 
every time I call it? If yes, can this behaviour be changed? Or, is 
there a way - maybe that is rather a mod_perl question - to compile perl 
scripts (modulest, etc.) in runtime and keep them compiled in memory and 
shared between Apache childs?

Your suggestions?

Thanks,
- Csongor



---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: Response->Include

Posted by Josh Chamas <jo...@chamas.com>.
Csongor Fagyal wrote:
>>
> Actually I have my home-grown templating system, and I had this idea to 
> take the templates and convert them to ASP, since my parser is very 
> slow, while mod_perl scripts are not :-). One other way would be to 
> generate ASP files and write them to disk, but I tend to dislike that idea.
> Apache::ASP->Loader() is fine, but I do not like the idea of compiling 
> scripts at server startup. My templates change too frequently for that.
> 

One thing that might be easy enough to do is to create a tmp directory
that is included in IncludesDir and write your ASP file there, then
include it after you have done your compilation.  That way it would
use the existing caching functionality if the runtime parsing would
not be fast enough for you.

--Josh
________________________________________________________________
Josh Chamas, Founder                   phone:925-552-0128
Chamas Enterprises Inc.                http://www.chamas.com
NodeWorks Link Checking                http://www.nodeworks.com


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: Response->Include

Posted by Csongor Fagyal <co...@conceptonline.hu>.
>
>
>> Hi,
>>
>> If I understand correctly, <!--#include file="aspfile" 
>> args=@args-->compiles aspfile only once, and consequtive calls only 
>> pass @args to the precompiled script. I guess the same is done when I 
>> use $Response->Include($filename, @args). But what happens if I use
>
>
> Yes, it actually compiles to $Response->Include() on the backend.
>
>> $Response->Include(\$script_text, @args)? Is $srcipt_text recomplied 
>> every time I call it? If yes, can this behaviour be changed? Or, is 
>
>
> Yes, the script is recompiled each time.  The reason is that since
> the text is not being loaded from a static file, it is assumed to
> be dynamically generated.  If Apache::ASP were to cache compilations
> of dynamically generated code, this would be a large memory leak
> each time the script were to be called.
>
>> there a way - maybe that is rather a mod_perl question - to compile 
>> perl scripts (modulest, etc.) in runtime and keep them compiled in 
>> memory and shared between Apache childs?
>
>
> Sure, one way to cache dynamic code compilations that have no name
> would be to simply keep the subroutine reference that it is compiled
> to looked up by something like an MD5 checksum of the code itself. 

Yep, I was thinking about something like that.

> Something that could make things better would be a parse cache
> to cache the compilation of the ASP script to perl code, but still
> leave the perl code to perl eval of generated subroutine not cached.
> I have thought about adding a parse cache before, but I haven't
> heard of people needing this yet, perhaps because of using things
> like Apache::ASP->Loader() is good enough to cache compilations,
> or maybe Apache::ASP parsing is generally fast enough.

Actually I have my home-grown templating system, and I had this idea to 
take the templates and convert them to ASP, since my parser is very 
slow, while mod_perl scripts are not :-). One other way would be to 
generate ASP files and write them to disk, but I tend to dislike that idea.
Apache::ASP->Loader() is fine, but I do not like the idea of compiling 
scripts at server startup. My templates change too frequently for that.

Hmmm, I guess I need to find a more complex method... say, I 
"precompile" my templates and store them in $Application, while I point 
StateDir to the ramdisk. (As the matter of fact, I won't even need 
$Application if I use ramdisk...)

- Csongor


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: Response->Include

Posted by Josh Chamas <jo...@chamas.com>.
Csongor Fagyal wrote:
> Hi,
> 
> If I understand correctly, <!--#include file="aspfile" 
> args=@args-->compiles aspfile only once, and consequtive calls only pass 
> @args to the precompiled script. I guess the same is done when I use 
> $Response->Include($filename, @args). But what happens if I use 

Yes, it actually compiles to $Response->Include() on the backend.

> $Response->Include(\$script_text, @args)? Is $srcipt_text recomplied 
> every time I call it? If yes, can this behaviour be changed? Or, is 

Yes, the script is recompiled each time.  The reason is that since
the text is not being loaded from a static file, it is assumed to
be dynamically generated.  If Apache::ASP were to cache compilations
of dynamically generated code, this would be a large memory leak
each time the script were to be called.

> there a way - maybe that is rather a mod_perl question - to compile perl 
> scripts (modulest, etc.) in runtime and keep them compiled in memory and 
> shared between Apache childs?

Sure, one way to cache dynamic code compilations that have no name
would be to simply keep the subroutine reference that it is compiled
to looked up by something like an MD5 checksum of the code itself.

Something that could make things better would be a parse cache
to cache the compilation of the ASP script to perl code, but still
leave the perl code to perl eval of generated subroutine not cached.
I have thought about adding a parse cache before, but I haven't
heard of people needing this yet, perhaps because of using things
like Apache::ASP->Loader() is good enough to cache compilations,
or maybe Apache::ASP parsing is generally fast enough.

Regards,

Josh

________________________________________________________________
Josh Chamas, Founder                   phone:925-552-0128
Chamas Enterprises Inc.                http://www.chamas.com
NodeWorks Link Checking                http://www.nodeworks.com


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org