|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
vorapoap Smarty Rookie
Joined: 22 Dec 2009 Posts: 32
|
Posted: Thu Jul 21, 2011 12:36 pm Post subject: Anyone notice that APC fails to cache any -compiled- files |
|
|
You don't need CacheResource APC in some thread of this forum to produce this problem.
Around line 433 in sysplugins/smarty_internal_template.php
Code: |
//if (function_exists('apc_compile_file')) var_exporT(apc_compile_file($this->getCompiledFilepath()));
include($this->getCompiledFilepath ());
|
Please note that the first line is added to test APC
apc_compile_file always returns TRUE but such file isn't reported as compiled by apc.php
If I change 'include' to 'include_once', the compiled file get compiled and stored by APC. However, you can't use include_once in the code there, since Smarty will fail to re-include any templates.
I have tried changing what returned by getCompiledFilepath($_template).. but same result.
BTW, My platform is very dynamic, Smarty cache is always disabled.
This seems like a bug in APC, but I hope to find a way to get around this without fixing APC and waiting for php_apc.dll 64bit running on Windows.
One thing I can do is to tell Smarty to include_once at first call and then do include on the next call, but I really don't know whether APC will use the compiled file by include_once or just re-include the file again... This is probably useless then. |
|
Back to top |
|
vorapoap Smarty Rookie
Joined: 22 Dec 2009 Posts: 32
|
Posted: Thu Jul 21, 2011 12:46 pm Post subject: |
|
|
As expected, include_once gets APC to store a file in OPCODE, but sequence calls to include doesn't use the OPCODE, it read directly from file system.
I know this by looking at the Hits value in APC.php
However, it is still better than nothing.
At least this will speed up the first call to include_once in any HTTP request |
|
Back to top |
|
rodneyrehm Administrator
Joined: 30 Mar 2007 Posts: 674 Location: Germany, border to Switzerland
|
Posted: Thu Jul 21, 2011 1:12 pm Post subject: |
|
|
With Smarty3.1 (DEV) you actually COULD replace the include by an include_once. |
|
Back to top |
|
vorapoap Smarty Rookie
Joined: 22 Dec 2009 Posts: 32
|
Posted: Thu Jul 21, 2011 3:49 pm Post subject: |
|
|
Oh this is great! Thank you very much
Last time I switched to 3.1, I got many errors with my old apps.
but today I got only one error with a new application and framework.
Here is the place to replace
smarty_internal_templatebase.php around line:139-147
Code: |
if (!$_template->compiled->loaded) {
include_once($_template->compiled->filepath);
if ($_template->mustCompile) {
// recompile and load again
$_template->compileTemplateSource();
include_once($_template->compiled->filepath);
}
$_template->compiled->loaded = true;
}
|
|
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Jul 21, 2011 4:02 pm Post subject: |
|
|
The second include must stay as it was. Otherwise templates recompiled because of modifcation will not be rendered at the current call.
Code: | if (!$_template->compiled->loaded) {
include_once($_template->compiled->filepath);
if ($_template->mustCompile) {
// recompile and load again
$_template->compileTemplateSource();
include($_template->compiled->filepath);
}
$_template->compiled->loaded = true;
} |
|
|
Back to top |
|
rodneyrehm Administrator
Joined: 30 Mar 2007 Posts: 674 Location: Germany, border to Switzerland
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|