Make phpBB faster/liter by replacing dynamic strings with static one

General discussion of development ideas and the approaches taken in the 3.x branch of phpBB. The current feature release of phpBB 3 is 3.3/Proteus.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.3.x. If you need support for phpBB 3.3.x please visit the 3.3.x Support Forum on phpbb.com.

If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
Shaban Sunal
Registered User
Posts: 5
Joined: Fri Aug 17, 2012 6:24 am

Make phpBB faster/liter by replacing dynamic strings with static one

Post by Shaban Sunal »

Hi everyone! :mrgreen: I was just customizing my phpBB's template..when i saw so many dynamic strings that could be made static..The first thing that comes in my mind is by replacing the "U" (Url variable) and "L" (Language variable) variables with the static ones; for example: {U_Search} ----> http://www.websiteurl.com/search.php and: {L_Search} ----> Search. Don't you think that making them static will avoid the template file calling everytime the many variables set in the common file and elsewhere (loading the server more than the necessary too), instead of just "showing" them to the user's browser? We will let Apache "calm down" and make the html work :mrgreen: thus LESS SERVER LOAD ;) I know you will say 'yeah but everyone needs to set his own static variable according to his website's url and language'...well..you can simply make a php form that modifies all the variables in the template files (or elsewhere) given the website's url that is inserted into the textfield, and for the language are taken from a preexisting language file ;) so what do you think about it? :)

Shaban Sunal
Registered User
Posts: 5
Joined: Fri Aug 17, 2012 6:24 am

Re: Make phpBB faster/liter by replacing dynamic strings with static one

Post by Shaban Sunal »

Nobody? at least..can someone tell me if i should do this or not? ;)

User avatar
Ger
Registered User
Posts: 293
Joined: Mon Jul 26, 2010 1:55 pm
Location: 192.168.1.100
Contact:

Re: Make phpBB faster/liter by replacing dynamic strings with static one

Post by Ger »

Don't you think they're variables for a reason?
Above message may contain errors in grammar, spelling or wrongly chosen words. This is because I'm not a native speaker. My apologies in advance.

Shaban Sunal
Registered User
Posts: 5
Joined: Fri Aug 17, 2012 6:24 am

Re: Make phpBB faster/liter by replacing dynamic strings with static one

Post by Shaban Sunal »

Yes, but once you are ready to make that forum live (and also before) variables/strings such as "{U_SEARCH}" and "{U_LOGIN}" for example will most likely remain fixed/unchanged...tell me..why in the world should you change the search url (one in the middle of the jungle of the other potential static strings of course)? I've already tried to and i saw an improvement in the CPU usage and the page's loading time ;)

User avatar
imkingdavid
Registered User
Posts: 1050
Joined: Thu Jul 30, 2009 12:06 pm

Re: Make phpBB faster/liter by replacing dynamic strings with static one

Post by imkingdavid »

Well, for one thing, if you have multi-lingual users, you will not be able to take advantage of language packs if you hardcode the text into the template. Also, if you ever decide to change a string of text, and it appears in multiple locations, it is significantly more work to change it everywhere it appears than to simply change the language string in a single file.

One reason links are not hardcoded, aside from a similar reason above (not having to change multiple uses of the same link multiple times), internal links are passed through append_sid() so that the session is always sure to be kept. If you hardcode the links, in some cases your users may lose their session and have to re-login, which is an inconvenience for them.

In any case, keep in mind that if you hardcode all these links and URLs in your template, you will have a difficult time updating because the automatic updater will not know how to handle all of that, so you will have to do it manually.

I doubt that any speed increase brought about by removing template variables is significant enough to justify such a major change.
I do custom MODs. PM for a quote!
View My: MODs | Portfolio
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: Make phpBB faster/liter by replacing dynamic strings with static one

Post by callumacrae »

It's a negligible performance gain, in my opinion.
Made by developers, for developers!
My blog

Shaban Sunal
Registered User
Posts: 5
Joined: Fri Aug 17, 2012 6:24 am

Re: Make phpBB faster/liter by replacing dynamic strings with static one

Post by Shaban Sunal »

imkingdavid wrote:Well, for one thing, if you have multi-lingual users, you will not be able to take advantage of language packs if you hardcode the text into the template. Also, if you ever decide to change a string of text, and it appears in multiple locations, it is significantly more work to change it everywhere it appears than to simply change the language string in a single file.

One reason links are not hardcoded, aside from a similar reason above (not having to change multiple uses of the same link multiple times), internal links are passed through append_sid() so that the session is always sure to be kept. If you hardcode the links, in some cases your users may lose their session and have to re-login, which is an inconvenience for them.

In any case, keep in mind that if you hardcode all these links and URLs in your template, you will have a difficult time updating because the automatic updater will not know how to handle all of that, so you will have to do it manually.

I doubt that any speed increase brought about by removing template variables is significant enough to justify such a major change.
That wouldn't be a problem; you don't need to edit every string by hand one by one..you could make a php file with a str_replace function just to say one. You're right 'if you ever decide' ;) no one would be so insane to go changing a string every now and then..the only reasons can be if you change domain/folder. But anyway the work is done one time, and not everytime like when the pages are loaded, get it?
I just changed some other strings and i've no error of any sort, including that of sessions..i'm still logged in ;) Can you give me some of the incriminated strings?
callumacrae wrote:It's a negligible performance gain, in my opinion.
Well..consider that the CPU load decreased by a 29% ;)

User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 1904
Joined: Thu Mar 02, 2006 4:29 pm
Location: Earth
Contact:

Re: Make phpBB faster/liter by replacing dynamic strings with static one

Post by DavidIQ »

You completely ignored the part about multi-languages. If we were to go with what you're suggesting then there would have to be multiple versions of template files if there are different languages available on a board. I'm sure going through all template files to produce the desired language to display won't do your CPU usage any favors either. ;)

The template engine in 3.1 has already been redone so I'm pretty sure you'll be seeing improvements there anyways.
Image

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: Make phpBB faster/liter by replacing dynamic strings with static one

Post by Oleg »

It is fairly straightforward to perform this replacement on a single installation via regular expressions. Therefore I would like to see some benchmarks. Also, with and without APC for 4 total benchmarks.

drathbun
Registered User
Posts: 72
Joined: Wed Feb 15, 2006 6:40 pm
Location: Texas
Contact:

Re: Make phpBB faster/liter by replacing dynamic strings with static one

Post by drathbun »

I find it hard to believe that a few variable versus static replacements dropped cpu utilization by nearly a third. :-?
Sometimes you're the windshield, sometimes you're the bug.

Post Reply