View previous topic :: View next topic |
Author |
Message |
scdgro Smarty Regular
Joined: 24 May 2003 Posts: 39 Location: Netherlands
|
Posted: Wed Oct 21, 2009 7:18 am Post subject: Smarty 3 really faster compared to 2.6 ? |
|
|
Yesterday i decided to give the 3 version a try.
After some minor modifications it ran without problems..
The only thing i can't understand is its speed LOSS by 5 times.
When i use the 2.6 engine with force_compile = on, I have a page which is loaded in approx 270 ms.
With the 3.0 engine, every page load is approx 1 - 1.13 seconds.
With force compile = off, there is no real difference in page load times, altough with the 3.0 a fraction slower.
All have been tested / seen with firefox and the firebug extensions.
Am i missing something, which affects the speed so negative ?
I know that php5 is and must be faster than 4.
Are there thing i could/should try to improve speed ? |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Oct 21, 2009 1:24 pm Post subject: |
|
|
During compilation Smarty3 is generally slower as Smarty2 as for more flexibility and mainability it uses a lexer/parser concept. For production systems it should not be a problem as you will have there normally force_compile turned off.
For both compiling and general speed some optimizations still in progress.
If you don't change your templates anymore you can turn compile_check off to get better performance.
Also your Server should have the APC cache enabled. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Oct 21, 2009 4:32 pm Post subject: |
|
|
compiling in Smarty 3 may be a bit slower, but run-time performance should be quicker. can you give an example bit of code that is problematic? |
|
Back to top |
|
scdgro Smarty Regular
Joined: 24 May 2003 Posts: 39 Location: Netherlands
|
Posted: Fri Oct 23, 2009 6:09 pm Post subject: |
|
|
My codebase is very big now so it's not that easy to give a short example i guess.
As far as i can see now, it is definitly the compiler which is the naughty boy. |
|
Back to top |
|
ryanhargrave Smarty n00b
Joined: 01 Nov 2009 Posts: 4
|
Posted: Sun Nov 01, 2009 9:21 pm Post subject: |
|
|
I saw pretty much the same thing with this release of Beta1. But not that much slower.
Smarty 2.x Averaged: 0.0315
Smarty 3.0B1 Averaged: 0.0376
Not noticeably slower but def consistently slower. I'm not using the deep down power of Smarty just simple includes, conditionals and tokens. This is with force_compile on, in our testing environment.
Also noticed that I had to change:
$smarty->template_dir = '/application/';
to
$smarty->template_dir = 'application/';
in the upgrade.
Last edited by ryanhargrave on Mon Nov 02, 2009 2:13 pm; edited 1 time in total |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Nov 02, 2009 12:25 am Post subject: |
|
|
is that during compiling or runtime? |
|
Back to top |
|
ryanhargrave Smarty n00b
Joined: 01 Nov 2009 Posts: 4
|
Posted: Mon Nov 02, 2009 2:12 pm Post subject: |
|
|
I'm sorry.. that was with force compile "on". The times were elapsed times from the start of the intial page (which includes all the other framework calls) till right after the $smarty->display() call. So they aren't Smarty specific generation times but just comaprison times when the only change is moving to Smarty 3.
It's also with APC enabled.
I mean we're talking 6 1000th of a second slower on a page with a with a few fetch() calls and maybe 100 tokens, so it's nothing I'm too concerned about right now. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Nov 02, 2009 3:07 pm Post subject: |
|
|
Yes force_compile will certainly not be "speedy", which is also the case in Smarty 2. The focus of Smarty 3 performance gains has been on the run-time side, although Uwe has been able to speed up the compiler to speeds very comparable to the Smarty 2 compiler. As you are saying, within microseconds. I'd like to hear the benchmark difference for your production run-time. |
|
Back to top |
|
mb_sa Smarty n00b
Joined: 03 Nov 2009 Posts: 1
|
Posted: Tue Nov 03, 2009 1:14 pm Post subject: |
|
|
Hello,
according to my results Smarty 2 is faster than Smarty 3.
Best regards.
TEST ENVIRONMENT
WinXP SP2
PHP Version 5.2.3 with eAccelerator v0.9.5.1
Mysql Server version: 5.0.45-community-nt-log (Client API version 5.0.37)
Apache/2.2.4 (Win32)
SMARTY 2
not compiled template:
$compile_check = true;
$force_complie = true;
The results measured with Xdebug.
load #1: 11.0 ms
load #2: 10.2 ms
load #3: 11.0 ms
load #4: 12.0 ms
load #5: 11.0 ms
min: 10.2 ms
max: 12.0 ms
compiled template:
$compile_check = false;
$force_complie = false;
The results measured with Xdebug.
load #1: 5.1 ms
load #2: 5.0 ms
load #3: 5.0 ms
load #4: 5.2 ms
load #5: 4.9 ms
min: 4.9 ms
max: 5.2 ms
AB (compiled template)
$compile_check = false;
$force_complie = false;
The results measured with the Apache bench (AB).
ab -n 1000 -c 100 url
1. time taken for tests: 34.25 sec
2. time taken for tests: 29.43 sec
3. time taken for tests: 31.28 sec
SMARTY 3
not compiled template:
$compile_check = true;
$force_complie = true;
The results measured with Xdebug.
load #1: 42.0 ms
load #2: 60.0 ms
load #3: 42.0 ms
load #4: 60.0 ms
load #5: 56.0 ms
min: 42.0 ms
max: 56.0 ms
compiled template:
$compile_check = false;
$force_complie = false;
The results measured with Xdebug.
load #1: 7.8 ms
load #2: 9.2 ms
load #3: 9.3 ms
load #4: 9.1 ms
load #5: 9.2 ms
min: 7.8 ms
max: 9.3 ms
AB (compiled template)
$compile_check = false;
$force_complie = false;
The results measured with the Apache bench (AB).
ab -n 1000 -c 100 url
1. time taken for tests: 87.75 sec
2. time taken for tests: 83.96 sec
3. time taken for tests: 86.43 sec |
|
Back to top |
|
king_2 Smarty Rookie
Joined: 10 Nov 2009 Posts: 8
|
Posted: Tue Nov 10, 2009 2:25 pm Post subject: Same situation for me |
|
|
I tried out Smarty3 on Win32 and on FreeBSD - same result.
Smarty 3, compile_check=true, force_compile=false, caching enabled, still slower than Smarty2.
But I after testing I found many .tmp files in template_c path. May be, this is an error in compiler, that forces compiler to re-compile or re-cache already compiled and cached files? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Nov 10, 2009 3:11 pm Post subject: |
|
|
What is the contents of the templates you are testing? |
|
Back to top |
|
king_2 Smarty Rookie
Joined: 10 Nov 2009 Posts: 8
|
Posted: Tue Nov 10, 2009 3:15 pm Post subject: |
|
|
I make blocks using fetch, then display index.tpl using theese blocks as {$BLOCK.content}, for example, or {$BLOCK.menu}.
Or you want to know something else? |
|
Back to top |
|
Xanderby Smarty n00b
Joined: 10 Nov 2009 Posts: 4
|
Posted: Fri Nov 13, 2009 7:13 am Post subject: |
|
|
I'm seeing a rather large performance hit as well. Below are ab bench results:
Smart 3.0b2 (First Run)
Code: |
Benchmarking 127.0.0.1 (be patient).....done
Server Software: Apache/2.2.14
Server Hostname: 127.0.0.1
Server Port: 80
Document Path: /egloo/
Document Length: 3626 bytes
Concurrency Level: 10
Time taken for tests: 14.763 seconds
Complete requests: 100
Failed requests: 1
(Connect: 0, Receive: 0, Length: 1, Exceptions: 0)
Write errors: 0
Total transferred: 413671 bytes
HTML transferred: 358974 bytes
Requests per second: 6.77 [#/sec] (mean)
Time per request: 1476.271 [ms] (mean)
Time per request: 147.627 [ms] (mean, across all concurrent requests)
Transfer rate: 27.36 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.4 0 4
Processing: 768 1457 262.5 1445 2658
Waiting: 767 1456 261.9 1445 2658
Total: 768 1458 262.5 1445 2658
Percentage of the requests served within a certain time (ms)
50% 1445
66% 1528
75% 1605
80% 1638
90% 1744
95% 1923
98% 2144
99% 2658
100% 2658 (longest request) |
Smart 3.0b2 (Second Run)
Code: | This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient).....done
Server Software: Apache/2.2.14
Server Hostname: 127.0.0.1
Server Port: 80
Document Path: /egloo/
Document Length: 3626 bytes
Concurrency Level: 10
Time taken for tests: 15.453 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 417300 bytes
HTML transferred: 362600 bytes
Requests per second: 6.47 [#/sec] (mean)
Time per request: 1545.266 [ms] (mean)
Time per request: 154.527 [ms] (mean, across all concurrent requests)
Transfer rate: 26.37 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.3 0 2
Processing: 940 1523 203.4 1539 1935
Waiting: 940 1522 203.3 1539 1935
Total: 941 1523 203.4 1539 1935
Percentage of the requests served within a certain time (ms)
50% 1539
66% 1618
75% 1691
80% 1708
90% 1772
95% 1856
98% 1931
99% 1935
100% 1935 (longest request) |
Smart 2.6 (First Run)
Code: | This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient).....done
Server Software: Apache/2.2.14
Server Hostname: 127.0.0.1
Server Port: 80
Document Path: /egloo/
Document Length: 3623 bytes
Concurrency Level: 10
Time taken for tests: 3.146 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 417000 bytes
HTML transferred: 362300 bytes
Requests per second: 31.78 [#/sec] (mean)
Time per request: 314.615 [ms] (mean)
Time per request: 31.462 [ms] (mean, across all concurrent requests)
Transfer rate: 129.44 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.5 0 4
Processing: 91 308 98.5 324 467
Waiting: 90 308 98.3 317 467
Total: 91 309 98.5 324 467
Percentage of the requests served within a certain time (ms)
50% 324
66% 363
75% 386
80% 401
90% 433
95% 450
98% 457
99% 467
100% 467 (longest request) |
Smart 2.6 (Second Run):
Code: | This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient).....done
Server Software: Apache/2.2.14
Server Hostname: 127.0.0.1
Server Port: 80
Document Path: /egloo/
Document Length: 3623 bytes
Concurrency Level: 10
Time taken for tests: 3.171 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 417000 bytes
HTML transferred: 362300 bytes
Requests per second: 31.54 [#/sec] (mean)
Time per request: 317.076 [ms] (mean)
Time per request: 31.708 [ms] (mean, across all concurrent requests)
Transfer rate: 128.43 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.5 0 3
Processing: 93 312 122.9 308 661
Waiting: 92 310 123.4 308 661
Total: 93 312 123.0 308 661
Percentage of the requests served within a certain time (ms)
50% 308
66% 356
75% 383
80% 403
90% 462
95% 566
98% 614
99% 661
100% 661 (longest request)
|
The template being assembled is the following:
Code: | <!--{* Ton of Comments *}-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>eGloo | Welcome</title>
<link href="css/extMainRoot.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="javascript/jquery.js"></script>
<script type="text/javascript" src="javascript/form.js"></script>
<script type="text/javascript" src="javascript/externalMainInit.js"></script>
</head>
<body>
<div style="position:relative;width:100%;height:100%;">
<div id="container">
<div id="shell">
<div id="top">
<div id="logo"><img src="images/logo.gif" alt="eGloo" width="304" height="138" /></div>
<div id="form">
<form name="login" action="/account/processLogin/" method="get" style="overflow:hidden;">
<input id="username" type="text" name="username" size="17" class="field" value="username"/>
<br />
<input id="password" type="text" name="password" size="17" class="field" value="password"/>
<div id="elements">
<div id="login">login</div>
<span class="spantext"> | </span>
<div id="join">join</div>
<span class="spantext"> | </span>
<a href="browse" id="browse">browse</a>
<span class="spantext"> | </span>
<div id="tour">tour</div>
</div>
<input type="submit" name="submit" style="display:none;" />
</form>
</div>
<div class="halo">halo one: beta | svn revision: <!--{$svnVersion}--> </div>
<div id="updates">
<span class="footer_option link">eGloo Blog</span>
<span class="spantext2"> | </span>
<span class="footer_option link">Latest Updates</span>
</div>
<div id="loadingImage"><img src="images/ajax-loader.gif" alt="Loading..." width="32" height="32" /></div>
<div id="loginFailed"></div>
<div id="forgotPassword" class="link">forgot password?</div>
<!--{*
<div id="forgotPassword"><a href="/account/viewForgotAccountPasswordForm/">forgot password?</a></div>
*}-->
</div>
</div>
<div id="content">
<div id="content_text" style="color:black"></div>
</div>
</div>
</div>
<div id="copyright">Copyright © 2007 eGloo, LLC. All rights reserved.</div>
<div id="footer">
<span class="footer_option link">Terms of Use</span>
<span class="spantext2"> | </span>
<span class="footer_option link">Privacy Policy</span>
<span class="spantext2"> | </span>
<span class="footer_option link">Help</span>
<span class="spantext2"> | </span>
<span class="footer_option link">Job Opportunities</span>
<span class="spantext2"> | </span>
<span class="footer_option link">Media Info</span>
<span class="spantext2"> | </span>
<span class="footer_option link">About Us</span>
<span class="spantext2"> | </span>
<span class="footer_option link">Contact Us</span>
</div>
</body>
</html>
|
Hideous HTML, but that's it. This is what is compiled out:
Code: | <?php if(!defined('SMARTY_DIR')) exit('no direct access allowed'); ?>
<?php $_smarty_tpl->decodeProperties('a:1:{s:15:"file_dependency";a:1:{s:10:"F815275764";a:2:{i:0;s:147:"/Library/Application Support/eGloo/Applications/eGloo/Default/InterfaceBundles/OverlayInterface/XHTML/ExternalMainPage/ExternalMainPageBaseForm.tpl";i:1;i:1258093247;}}}'); ?>
<?php /* Smarty version Smarty-3.0b2, created on 2009-11-13 06:43:07
compiled from "/Library/Application Support/eGloo/Applications/eGloo/Default/InterfaceBundles/OverlayInterface/XHTML/ExternalMainPage/ExternalMainPageBaseForm.tpl" */ ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>eGloo | Welcome</title>
<link href="css/extMainRoot.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="javascript/jquery.js"></script>
<script type="text/javascript" src="javascript/form.js"></script>
<script type="text/javascript" src="javascript/externalMainInit.js"></script>
</head>
<body>
<div style="position:relative;width:100%;height:100%;">
<div id="container">
<div id="shell">
<div id="top">
<div id="logo"><img src="images/logo.gif" alt="eGloo" width="304" height="138" /></div>
<div id="form">
<form name="login" action="/account/processLogin/" method="get" style="overflow:hidden;">
<input id="username" type="text" name="username" size="17" class="field" value="username"/>
<br />
<input id="password" type="text" name="password" size="17" class="field" value="password"/>
<div id="elements">
<div id="login">login</div>
<span class="spantext"> | </span>
<div id="join">join</div>
<span class="spantext"> | </span>
<a href="browse" id="browse">browse</a>
<span class="spantext"> | </span>
<div id="tour">tour</div>
</div>
<input type="submit" name="submit" style="display:none;" />
</form>
</div>
<div class="halo">halo one: beta | svn revision: <?php echo $_smarty_tpl->getVariable('svnVersion')->value;?>
</div>
<div id="updates">
<span class="footer_option link">eGloo Blog</span>
<span class="spantext2"> | </span>
<span class="footer_option link">Latest Updates</span>
</div>
<div id="loadingImage"><img src="images/ajax-loader.gif" alt="Loading..." width="32" height="32" /></div>
<div id="loginFailed"></div>
<div id="forgotPassword" class="link">forgot password?</div>
</div>
</div>
<div id="content">
<div id="content_text" style="color:black"></div>
</div>
</div>
</div>
<div id="copyright">Copyright © 2007 eGloo, LLC. All rights reserved.</div>
<div id="footer">
<span class="footer_option link">Terms of Use</span>
<span class="spantext2"> | </span>
<span class="footer_option link">Privacy Policy</span>
<span class="spantext2"> | </span>
<span class="footer_option link">Help</span>
<span class="spantext2"> | </span>
<span class="footer_option link">Job Opportunities</span>
<span class="spantext2"> | </span>
<span class="footer_option link">Media Info</span>
<span class="spantext2"> | </span>
<span class="footer_option link">About Us</span>
<span class="spantext2"> | </span>
<span class="footer_option link">Contact Us</span>
</div>
</body>
</html>
|
This is the cache file next to the compiled file (but not in the cache directory):
Code: | <?php if(!defined('SMARTY_DIR')) exit('no direct access allowed'); ?>
<?php $_smarty_tpl->decodeProperties('a:1:{s:15:"file_dependency";a:1:{s:10:"F815275764";a:2:{i:0;s:147:"/Library/Application Support/eGloo/Applications/eGloo/Default/InterfaceBundles/OverlayInterface/XHTML/ExternalMainPage/ExternalMainPageBaseForm.tpl";i:1;i:1258093247;}}}'); ?>
<?php /* Smarty version Smarty-3.0b2, created on 2009-11-13 06:44:50
compiled from "/Library/Application Support/eGloo/Applications/eGloo/Default/InterfaceBundles/OverlayInterface/XHTML/ExternalMainPage/ExternalMainPageBaseForm.tpl" */ ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>eGloo | Welcome</title>
<link href="css/extMainRoot.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="javascript/jquery.js"></script>
<script type="text/javascript" src="javascript/form.js"></script>
<script type="text/javascript" src="javascript/externalMainInit.js"></script>
</head>
<body>
<div style="position:relative;width:100%;height:100%;">
<div id="container">
<div id="shell">
<div id="top">
<div id="logo"><img src="images/logo.gif" alt="eGloo" width="304" height="138" /></div>
<div id="form">
<form name="login" action="/account/processLogin/" method="get" style="overflow:hidden;">
<input id="username" type="text" name="username" size="17" class="field" value="username"/>
<br />
<input id="password" type="text" name="password" size="17" class="field" value="password"/>
<div id="elements">
<div id="login">login</div>
<span class="spantext"> | </span>
<div id="join">join</div>
<span class="spantext"> | </span>
<a href="browse" id="browse">browse</a>
<span class="spantext"> | </span>
<div id="tour">tour</div>
</div>
<input type="submit" name="submit" style="display:none;" />
</form>
</div>
<div class="halo">halo one: beta | svn revision: <?php echo $_smarty_tpl->getVariable('svnVersion')->value;?>
</div>
<div id="updates">
<span class="footer_option link">eGloo Blog</span>
<span class="spantext2"> | </span>
<span class="footer_option link">Latest Updates</span>
</div>
<div id="loadingImage"><img src="images/ajax-loader.gif" alt="Loading..." width="32" height="32" /></div>
<div id="loginFailed"></div>
<div id="forgotPassword" class="link">forgot password?</div>
</div>
</div>
<div id="content">
<div id="content_text" style="color:black"></div>
</div>
</div>
</div>
<div id="copyright">Copyright © 2007 eGloo, LLC. All rights reserved.</div>
<div id="footer">
<span class="footer_option link">Terms of Use</span>
<span class="spantext2"> | </span>
<span class="footer_option link">Privacy Policy</span>
<span class="spantext2"> | </span>
<span class="footer_option link">Help</span>
<span class="spantext2"> | </span>
<span class="footer_option link">Job Opportunities</span>
<span class="spantext2"> | </span>
<span class="footer_option link">Media Info</span>
<span class="spantext2"> | </span>
<span class="footer_option link">About Us</span>
<span class="spantext2"> | </span>
<span class="footer_option link">Contact Us</span>
</div>
</body>
</html>
|
I have both compile_check and force_compile set to false.
I really don't see anything too insane in this template that could be causing a 5x slowdown... |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Nov 13, 2009 2:16 pm Post subject: |
|
|
Thanks for the info, we're looking into it. |
|
Back to top |
|
Xanderby Smarty n00b
Joined: 10 Nov 2009 Posts: 4
|
Posted: Fri Nov 20, 2009 5:09 pm Post subject: |
|
|
For eGloo, it turned out this was a product of the two autoloaders conflicting after the changes to the Smarty autoloader from Smarty 2 to Smarty 3. The problem appears to be resolved. |
|
Back to top |
|
|