MyBB Hacks

Full Version: Language Optimizations (beta)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
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)
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
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.
yup, just noticed to day, it's loading much better in the usercp, and member_register page!
thanks mate. and thanks for the fix
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
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?
^ 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.
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
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
(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
Pages: 1 2 3
Reference URL's