RE: [SMARTY] Long compile time problems: I think I figured it out
| From: | Josh Johnson | Date: | Mon, 19 Aug 2002 21:33:17 +0000 |
| Subject: | RE: [SMARTY] Long compile time problems: I think I figured it out | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-5764@lists.php.net to get a copy of this message | ||
After some tests and poking around, I was able to pinpoint the problem
down to this exact scenario (I hadn't noticed it before because most of
the templates were made/initially compiled under windows):
A template has been created, then compiled for the first time by Smarty,
without a hitch.
The same template file gets altered, or more specifically, its timestamp
gets changed (i.e., I'd open it in vi and then save it without changing
the content)
I open the page that uses that template in a browser (or reload it), and
sometimes it will compile before Netscape gives up, sometimes it won't
(and I get a "document contains no data" alert; explorer sends its
stupid default 404-esq message in either case), but regardless it takes
at least 10 minutes, sometimes longer. At this point the directories
have been made in the templates_c directory (now that I think about it,
I never checked to see if the php file got created, but that's not
important now).
It only happens when a file is being compiled that was previously
compiled. If I remove the compiled template files (I just did a rm -rf
%* in the templates_c dir), it will compile without problems, unless I
change the file again.
I was looking through the BUGS file and noticed something about flock
not working properly in windows. I had noticed it before, but since this
server is running FreeBSD, I discounted it. This time around I tried
commenting out every occurrence of flock in Smarty.class.php (there's
two, one when the template is read, one when the compiled file is
written), to see what would happen. It worked fine. I tried just
commenting out the flock before the fwrite, but then the problem came
back (so something's happening during the read).
So my problem is sort of fixed. I'm not sure why flock is broken in this
context in this version of FreeBSD (I'm going to look into it), but that
seems to be what was causing the problem.
Now my question is, I assume that the flock calls are there for a
reason, are there any adverse affects I should be expecting from
removing the flock calls from Smarty.class.php? Does anyone know of any
specific problems that people have been having with flock under FreeBSD?
Or maybe just with php 4.2.2? If I find anything out I'll be sure to
post it to the mailing list.
Thanks again for your help.
-- Josh
-----Original Message-----
From: Travis Low [mailto:travis@dawnstar.org]
Sent: Sunday, August 18, 2002 9:09 PM
To: Josh Johnson
Cc: smarty-general@lists.php.net
Subject: Re: [SMARTY] Long compile time problems
If you can reliably reproduce the problem, then please provide some code
samples. The smaller the better. Also provide environment information
(OS, PHP
build, Smarty version, etc.).
cheers,
Travis
Josh Johnson wrote:
> Forgive me if this is out of turn, I'm new to mailing lists in
general,
> as well as to this group.
>
> I've been having a pesky problem with a site I'm developing that I
> couldn't find an answer to in the archives or the docs.
>
> For some reason, intermittently, when I change a template it will take
a
> long time for it to compile. Once it manages to compile, it runs fine.
> It takes so long that the browser will often time out. But it doesn't
> seem consistent. Some days it works speedily in true Smarty form,
other
> days it crawls. I haven't noticed a pattern yet.
>
> When it first happened, I immediately started checking my code and
> making sure the server wasn't overloaded, but it's happened on two
> different UNIX servers (when I was initially developing the site, I
was
> using Windows/Apache and didn't experience the problem), and I've
> streamlined my code. I can't see anything obvious that's causing the
> problem, except that when it happens, it only happens when I'm viewing
a
> page that contains a template that was just changed. It even happens
if
> I remove all of the function calls from a template.
>
> Is there anything that anyone can think of that might cause the
template
> compiler to run slow like this? I'm out of ideas, and willing to try
> anything that might help.
>
> Thanks for your help,
> -- Josh
>
>
>
--
Travis Low
<mailto:travis@dawnstar.org>
<http://dawnstar.org/travis>