X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   4.0.x performance improvement (https://forum.x-cart.com/showthread.php?t=24694)

geckoday 09-06-2006 09:26 PM

4.0.x performance improvement
 
I was running some profiling on CPU usage and ran into something that slows down every page considerably that was fixed in 4.1. In func.php function func_display find these lines and delete them:
PHP Code:

if (empty($templater->strict_resources) && ($r=func_bf_psc('r''asc'))!==false) {
$templater->strict_resources[] = $r;


These lines were deleted in 4.1.x so I'm pretty sure the change is safe. They seem to have something to do with getting a list of templates that should always be compiled, even if the compiled version already exists in templates_c.

I'm running this now and it doesn't cause any problems, but the performance improvement is dramatic.

NOTE: I have checked the upgrade packages and this fix applies only to 4.0.14 through 4.0.19.

inebriate 09-06-2006 10:29 PM

Re: 4.0.x performance improvement
 
Thanks for the tip! Seems to greatly improve the load times on my site, even cleared the cache just to make sure.

B00MER 09-07-2006 02:30 AM

Re: 4.0.x performance improvement
 
Nice find, defiantly a turbo boost :)

TJ Stephens 09-07-2006 08:22 AM

Re: 4.0.x performance improvement
 
Wow! Thank you. Seems to really improve speed on my site...

creative xpress 09-07-2006 08:36 AM

Re: 4.0.x performance improvement
 
Great Find!!!!!!!! My store is now loading in less that one second will more than 100 users. Thank you for sharing this!!!

Cameron

NightFire 09-07-2006 09:05 AM

Re: 4.0.x performance improvement
 
WOW !!!! It really makes a difference :|
Thanks for sharing this great solution.

augustash 09-07-2006 10:29 AM

Re: 4.0.x performance improvement
 
Friggin Wow. Does anyone know what these lines did. Don't want to find out later that an email notice or something is not working.

geckoday 09-07-2006 10:54 AM

Re: 4.0.x performance improvement
 
Quote:

Originally Posted by augustash
Friggin Wow. Does anyone know what these lines did. Don't want to find out later that an email notice or something is not working.

Yeah, my site went from 3 seconds to under a second. I've traced the code pretty good and am pretty darn sure it won't cause any problems removing it. Particularly as X-Cart removed it from 4.1. I think its leftover junk that forces product.tpl to always be compiled. X-Cart does a few unnatural acts with Smarty and perhaps there was a reason at one time but I have looked at it pretty hard and can't find any good reason for it.

augustash 09-07-2006 11:06 AM

Re: 4.0.x performance improvement
 
Well you would think that since they removed it from the new version that they could notify users of older versions of this. If everything continues to work properly this is not just oops I missed that thing. With the loads times now, I feel like I just stepped into a Porsche instead of a Saturn

Zaja 09-07-2006 04:35 PM

Re: 4.0.x performance improvement
 
Thanks Ralph, great/incredible speed improvement.... 8O

QVS 09-07-2006 11:46 PM

Re: 4.0.x performance improvement
 
yep chopped a second of loading time, top stuff ...thanks

kenwen 09-08-2006 02:44 AM

Re: 4.0.x performance improvement
 
call me stupid...but I can't find this file?

Zaja 09-08-2006 03:14 AM

Re: 4.0.x performance improvement
 
Quote:

Originally Posted by kenwen
...but I can't find this file?


xcart_root/include/func.php

balinor 09-08-2006 04:27 AM

Re: 4.0.x performance improvement
 
Wow...quite impressive! Makes you wonder how many other code blocks exist that shouldn't exist :)

carpeperdiem 09-08-2006 05:15 AM

Re: 4.0.x performance improvement
 
Quote:

Originally Posted by balinor
Wow...quite impressive! Makes you wonder how many other code blocks exist that shouldn't exist :)


I would guess 20% of the code can be eliminated. That guess is not based on anything more than a hunch. Not based on scientific info, or knowledge of the codebase... I'm just picking a number out of my a$$.

I must say that I have had 3 specific instances of learning about certain code sections in x-cart that are all about supporting legacy OS configs... at the expense of security and speed.

And I'm a rookie. Imagine what a pro could find...

One thing I'm learning - there are SO MANY varieties of unix/linux and so many variations, how can a developer keep up? And versions of php and mysql - and it's more than that... within newer versions, the end user can modify the active directives and turn it into whatever they want...

So X-Cart has to over-code to consider every possible config.

In a more perfect world, X-Cart would make a version of their cart that runs a specific minimum config, and that's that...

Ralph, thanks for your contributions. Although I'm running 4.1, it's nice to know that you're hanging out.

Jerrad 09-08-2006 07:07 AM

Re: 4.0.x performance improvement
 
Quote:

Originally Posted by Zaja
xcart_root/include/func.php


I have no problems finding the file, but I can't find the code that need to be deleted.
Below is my func_display from include/func.php

Code:

#
# Smarty->display wrapper
#
function func_display($tpl, &$templater, $to_display = true) {

        func_get_lng_chain($tpl, $templater);
        if($to_display == true) {
                $templater->display($tpl);
                if(defined("START_TIME")) {
                        global $__sql_time;
                        $all_time = func_microtime()-START_TIME;
                        echo '<!--<TIME all="'.$all_time.'" sql="'.$__sql_time.'" php="'.($all_time-$__sql_time).'">-->';
                }
        } else
                return $templater->fetch($tpl);
}


geckoday 09-08-2006 07:18 AM

Re: 4.0.x performance improvement
 
Quote:

Originally Posted by Jerrad
I have no problems finding the file, but I can't find the code that need to be deleted.
Below is my func_display from include/func.php

[


The code has already been removed from your func.php. Someone must have already found it and fixed it on your site.

Jerrad 09-08-2006 07:41 AM

Re: 4.0.x performance improvement
 
Quote:

Originally Posted by geckoday
The code has already been removed from your func.php. Someone must have already found it and fixed it on your site.


Thanks for the reply geckoday!
I just checked the original func.php from version 4.0.12 and the func_display code is exactly the same as in the func.php I'm using.

Pity, some speed improvement is always welcome.
Thanks anyway!

balinor 09-08-2006 08:18 AM

Re: 4.0.x performance improvement
 
Do a search in the file, it may be in a different place

Jerrad 09-08-2006 08:28 AM

Re: 4.0.x performance improvement
 
Quote:

Originally Posted by balinor
Do a search in the file, it may be in a different place


I already did and only found the func_display code in my first post.
Could it be that the func.php in version 4.0.12 is different from other 4.0.x versions?

jdiehl 09-08-2006 08:54 AM

Re: 4.0.x performance improvement
 
I was just looking at an installation that it was also missing in, it was 4.0.8 So i don't think it was in there for all versions of 4.0.x

geckoday 09-08-2006 09:27 AM

Re: 4.0.x performance improvement
 
Quote:

Originally Posted by jdiehl
I was just looking at an installation that it was also missing in, it was 4.0.8 So i don't think it was in there for all versions of 4.0.x

I just checked the upgrade packages and it was added in 4.0.14, removed in 4.1.

Jerrad 09-08-2006 01:43 PM

Re: 4.0.x performance improvement
 
Quote:

Originally Posted by geckoday
I just checked the upgrade packages and it was added in 4.0.14, removed in 4.1.


Thanks for figuring this out, geckoday!

TA 09-11-2006 08:34 PM

Re: 4.0.x performance improvement
 
The fountain of youth! Excellent!

Thanks

ecommerce 09-11-2006 10:27 PM

Re: 4.0.x performance improvement
 
geckoday...got any more???????????

Thanks!

geckoday 09-12-2006 09:59 AM

Re: 4.0.x performance improvement
 
Two I'm working on. One turns out its another rewrite in 4.1 but looks like it affects 4.0 at least back to 4.0.12. Has to do with $lng variables in templates. God that whole mess is ugly and boy did they do it bad in 4.0. 4.1 is even uglier but I think they fixed the performance end of it. I was going to try to retrofit it from 4.1 but its too nasty so I have a simplified version in the works. Iits horrible the price we pay for multilingual capabilities on a single language site. The second will speed up the product page if you use variants. The more variants the more improvement. Seems X-Cart asks for the tax rate for each variant - but the tax rate is only dependent on the product. So it goes through a ton of work for every variant when it only needs to do it once. They tried to cache some of that work but they screwed it up and it only works for logged in users. And they didn't cache the results at a higher level routine so it doesn't have that much affect. This one will apply to both 4.0 and 4.1. Stay tuned. I'll post these later this week or next week.

shan 09-13-2006 01:08 PM

Re: 4.0.x performance improvement
 
yes, a great increase on some sites.

Be good to get an official response from xcart on this one

Its about time they realeased a patch that maybe added a few indexes to the database and gave simple fixes to speed issues that they discovered while coding 4.1

considering that the bulk of users are using 4.0.x branch these days theres a lot of stores out there that could benefit

B00MER 09-19-2006 10:01 PM

Re: 4.0.x performance improvement
 
4.0 = a turtle with a massive product database. If it wasn't for the html catalog, 4.0 would almost be useless.

I'm curious to see how 4.1 can handle large amounts of data, has anyone loaded it up with a live, semi-high traffic store with 4.1 yet?

mayanetwork 09-25-2006 09:11 AM

Re: 4.0.x performance improvement
 
Will this fix work on version 4.0.6 or will it cause problems?

geckoday 09-25-2006 09:21 AM

Re: 4.0.x performance improvement
 
Quote:

Originally Posted by mayanetwork
Will this fix work on version 4.0.6 or will it cause problems?

No, the code only exsts in 4.0.14 - 4.0.19

Eggplant999 10-04-2006 06:45 PM

Re: 4.0.x performance improvement
 
Improved my load time from 3-4 seconds to roughly 1-2

Vacman 10-04-2006 10:32 PM

Re: 4.0.x performance improvement
 
Wow! So far so good - speedy delivery!

Audiolines 10-05-2006 10:59 AM

Re: 4.0.x performance improvement
 
am i the only one who doesnt really notice a difference?

Skateboards.com 10-07-2006 03:33 PM

Re: 4.0.x performance improvement
 
Quote:

Originally Posted by B00MER
4.0 = a turtle with a massive product database. If it wasn't for the html catalog, 4.0 would almost be useless.

I'm curious to see how 4.1 can handle large amounts of data, has anyone loaded it up with a live, semi-high traffic store with 4.1 yet?


Skateboards.com has quite a bit of traffic and we have about 20k SKU's online at any given time. I had to set up a dedicate physical server for the front-end and one for the backend. Before I tried it with the db/frontend sharing the server and the site was almost unusable if anything has to query the db.

-Rich

GMADMIN 10-12-2006 01:21 PM

Re: 4.0.x performance improvement
 
This seems to work great. Can you tell me, does it overlap in anyway with the following suggestion from websitecm -- or is it totally unrelated? Many thanks, Drew Oliver

"Smarty provides a method to increase speed by caching the templates so they do not need to be recompiled. This should NOT be used when you are making changes to your site templates, as no template changes will be recognized while the check is disabled. So if making changes, you will need to ensure this variable is set to "true."

You can enable template caching by opening the file "Smarty.class.php" in your smarty directory and editing this variable to "false":

/**
* This tells Smarty whether to check for recompiling or not. Recompiling
* does not need to happen unless a template or config file is changed.
* Typically you enable this during development, and disable for
* production.
*
* @var boolean
*/
var $compile_check = true;

geckoday 10-12-2006 06:17 PM

Re: 4.0.x performance improvement
 
Quote:

Originally Posted by GMADMIN
You can enable template caching by opening the file "Smarty.class.php" in your smarty directory and editing this variable to "false"

This is totally unrelated and the two can be used together.

wank3r 10-17-2006 02:50 PM

Re: 4.0.x performance improvement
 
This is the func.php inside the includes dir right ?

maildodge 10-21-2006 01:45 AM

Re: 4.0.x performance improvement
 
Wow, has improved my load time. Thanks.

Hopefully this wont cause any trouble.

Owl 10-25-2006 10:25 AM

Re: 4.0.x performance improvement
 
GREAT solution..

yages 01-11-2007 03:02 PM

Re: 4.0.x performance improvement
 
Makes a difference.
Is there any other adjustment you would recommend for excessive CPU useage


All times are GMT -8. The time now is 04:32 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.