Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Language Optimizations (beta)
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #1
Language Optimizations (beta)
You may be surprised how much you can optimize MyBB through it's language system...

How the MyBB language system works
There are a number of .lang.php files under /inc/languages/[your language]/ folder.
The language variables are stored as an $l array.  However, MyBB internally stores langvars in the $lang object.  So, every time a language file is loaded, there's a small delay in copying the contents of the $l array to the $lang object.
However, the main overhead is the preg_replace() function which is used to parse each language var.  This converts {1}, {2} etc to something which is usable by sprintf().

How this plugin works
This works by causing language vars to be directly assigned to the object, rather than performing a second copy.  Also, the langvars are preparsed, so that preg_replace() doesn't have to be run over each variable each time a language file is loaded.  Additionally, this uses single quotes, which is faster for PHP to parse than double quotes Tongue

Side effects?
Basically none.  This plugin will fix the AdminCP language editor, so everything will seem normal.  The only difference is perhaps if you edit the .lang.php files directly.  You'll notice that there's a slightly different format, and that {1}, {2} etc are preparsed to %1$s, %2$s etc.  Shouldn't be hard to figure out anyway.

The results?
On a test board, I got around a 10-30% reduction in page generation times.  Not that much, but then, there's little to lose here, so why not?

Installation
Upload to your /inc/plugins folder.  Make sure the appropriate language files are writable, for example, make sure you CHMOD /inc/languages/english and all files inside the folder to 0666.
After that, activate the plugin (note, on activation/deactivation, the plugin will rewrite all your .lang.php files).

Note: since this doesn't change MyBB core behaviour, plugins still using the older $l notation will work perfectly fine.  If you want to optimize those files however, simply edit them in the AdminCP language editor, and the file will be rewritten with the optimizations in place. (alternatively, reactivate the plugin)


Attached File(s)
.zip  langopt.zip (Size: 3.68 KB / Downloads: 739)

My Blog
(This post was last modified: 01-26-2008 11:53 AM by ZiNgA BuRgA.)
01-26-2008 11:50 AM
Find all posts by this user
pepotiger Offline
Junior Member
**
Posts: 18
Joined: Jan 2008
Post: #2
RE: Language Optimizations (beta)
I just take a backup for my lang files. and I'll give it a try on my live forums..
do you know zinga, one of the best things I like of you..
that you not just making an additions plugins, no you do make a needed plugins
thanks mate.

Edit: it's not to much optimization, but it's do optimized my forum little bet.
take the following example from my forum index page..
before the activition
Generated in 0.0770280 seconds (95.92% PHP / 4.08% MySQL)
MySQL Queries: 11 / Global Parsing Time: 0.0449259 / Memory Usage: 3.58 MB
PHP version: 5.2.4 / Server Load: / GZip Compression: Enabled

after?

Generated in 0.0761380 seconds (95.72% PHP / 4.28% MySQL)
MySQL Queries: 11 / Global Parsing Time: 0.0439799 / Memory Usage: 3.56 MB
PHP version: 5.2.4 / Server Load: / GZip Compression: Enabled[/code]
but as you said
there's little to lose here, so why not?

and an offtopic, there is error with your highlight plugin .
if you used the quick edit and added a code in the post you will get this error

Fatal error: Call to undefined function code_highlight() in
var/www/vhost/zingaburga.com/mybbhack/inc/plugins/coolcode.php on line 56
and the same whene adding a qouick replay or edit the post in full edit mode and even in posting new thread (I saw this error in this forum) so for now I removed the code tags in my post
(This post was last modified: 01-27-2008 04:47 AM by pepotiger.)
01-27-2008 04:17 AM
Find all posts by this user
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #3
RE: Language Optimizations (beta)
pepotiger Wrote:Edit: it's not to much optimization, but it's do optimized my forum little bet.
take the following example from my forum index page..
before the activition
Generated in 0.0770280 seconds (95.92% PHP / 4.08% MySQL)
MySQL Queries: 11 / Global Parsing Time: 0.0449259 / Memory Usage: 3.58 MB
PHP version: 5.2.4 / Server Load: / GZip Compression: Enabled

after?

Generated in 0.0761380 seconds (95.72% PHP / 4.28% MySQL)
MySQL Queries: 11 / Global Parsing Time: 0.0439799 / Memory Usage: 3.56 MB
PHP version: 5.2.4 / Server Load: / GZip Compression: Enabled[/code]
but as you said
there's little to lose here, so why not?
You have to take an average.
Because chances are, if you keep reloading the page, you'll get very different generation times.
And of course, depends on your setup.
Also, works better with pages which load a fair amount of langvars, like the UserCP.
Thanks for trying it though.

pepotiger Wrote:and an offtopic, there is error with your highlight plugin .
if you used the quick edit and added a code in the post you will get this error

Fatal error: Call to undefined function code_highlight() in
var/www/vhost/zingaburga.com/mybbhack/inc/plugins/coolcode.php on line 56
and the same whene adding a qouick replay or edit the post in full edit mode and even in posting new thread (I saw this error in this forum) so for now I removed the code tags in my post
Thanks for finding that - I forgot to upload an updated copy here.

My Blog
(This post was last modified: 01-27-2008 11:04 AM by ZiNgA BuRgA.)
01-27-2008 11:01 AM
Find all posts by this user
pepotiger Offline
Junior Member
**
Posts: 18
Joined: Jan 2008
Post: #4
RE: Language Optimizations (beta)
yup, just noticed to day, it's loading much better in the usercp, and member_register page!
thanks mate. and thanks for the fix
01-28-2008 01:06 AM
Find all posts by this user
dared Offline
Junior Member
**
Posts: 19
Joined: Jan 2008
Post: #5
RE: Language Optimizations (beta)
its awesome  realy amazing and realy realy err....
-good
-no
-nice?
-i dont think so
-perfe..
-i said no.
-insane?
-YESSSS Holy sh.t Biggrin i love you zinga Biggrin +rep
03-19-2008 12:55 AM
Find all posts by this user
dvb Offline
Junior Member
**
Posts: 11
Joined: Feb 2008
Post: #6
RE: Language Optimizations (beta)
wow, that's great, I really like fast sites so your plugin is my best choice, thanks a lot! Tongue

if I am not mistaken - right now you're part of the MyBB team, so why not suggesting that to them?

Cocktail Be a fountain, not a drain.
Rex Hudler
User Creativity is a drug I cannot live without.
Cecil B. DeMille
03-19-2008 10:43 AM
Visit this user's website Find all posts by this user
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #7
RE: Language Optimizations (beta)
^ The reason {x} format was used was to not confuse the translators, but since you've probably got your board already installed, there's no translators to confuse Tongue

But anyway, MyBB 1.4 has a much faster language handling routine, which makes this useless.  It basically parses the language var only when needed, which is much more efficient than doing it when loading the language.

My Blog
(This post was last modified: 03-19-2008 11:32 AM by ZiNgA BuRgA.)
03-19-2008 11:31 AM
Find all posts by this user
dvb Offline
Junior Member
**
Posts: 11
Joined: Feb 2008
Post: #8
RE: Language Optimizations (beta)
Good Biggrin

BTW, I can't get the emails that report about new replies in your board (EDIT: yes, this board)
I'm just receive an empty message

EDITED AGAIN:
now, I can receive mail reports about new replies but the rss doesn't work Frown

Cocktail Be a fountain, not a drain.
Rex Hudler
User Creativity is a drug I cannot live without.
Cecil B. DeMille
(This post was last modified: 03-27-2008 06:06 AM by dvb.)
03-19-2008 09:52 PM
Visit this user's website Find all posts by this user
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #9
RE: Language Optimizations (beta)
On this board?  I thought I fixed that one up...

I'll have to leave it to a little later, but thanks for reporting it anyway Tongue

My Blog
03-19-2008 10:37 PM
Find all posts by this user
dared Offline
Junior Member
**
Posts: 19
Joined: Jan 2008
Post: #10
RE: Language Optimizations (beta)
(03-19-2008 11:31 AM)ZiNgA BuRgA Wrote:  ^ The reason {x} format was used was to not confuse the translators, but since you've probably got your board already installed, there's no translators to confuse Tongue

But anyway, MyBB 1.4 has a much faster language handling routine, which makes this useless.  It basically parses the language var only when needed, which is much more efficient than doing it when loading the language.

by the way, im a translater too budy Biggrin mybbturkiye (turkish support)..
i am not confused.. its very simple to got it. Biggrin
anyway 1.4 is realy looks faster than 1.2.x

p.s. guests cant quick reply on here know i dont know why.. an one more thing i add you to my msn messeger (your @endlesparadigim & @hotmail adresses) can you accept me? i have talk about somethings.. i need your help


regards
03-27-2008 03:29 AM
Find all posts by this user

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: