MyBB Community Forums

Full Version: Preparser Cache (beta)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
BTW, whilst we're on the topic of optimization, I just tried a little language trick - changing the language files from $l[''] to $this-> (and {1} to %1$s, double quotes to single etc) seems to have sped things up quite a bit. Reduced my average page generation times by about 40%.

I guess {1} looks nicer than %1$s, but I'm not too sure it justifies the extra load...


Anyways, I'll be interested to see your plugin, Tikitiki! Smile
Now I thank you for this. I just made a code modification to class_parser.php that retrieves values from other websites, and because my home internet is very slow, server speed on localhost to parse this everytime i view the thread is too much, but the preparser took the time from 15 seconds to instantaneous...

Thanks!!
Hehe, preparser does have that ability. I'm also planning on releasing a code syntax highlighting mod. It's rather slow though, so the only feasable implementation is through preparsing.
There is always the geshi MyCode but I have trouble getting that to work, or it just sucks.

I have always wanted a HTML parser Wink
This plugin seems to work nicely, after some quick tests. Smile
blueparukia Wrote:There is always the geshi MyCode but I have trouble getting that to work, or it just sucks.

I have always wanted a HTML parser Wink
I've seen some boards with syntax highlighting tags, however, I've never seen the code for it.
The one I have is completely designed by me, without any prior knowledge of seeing any similar code.
Maybe that's why it's slow Toungue

Might look into that one you mentioned.
Alrighty here it is. The activation function might take a while depending on how many posts you have on your forum. Also if you know your PHP it'd be a good idea to seperate the preparserpost_trim function into a seperate file that rights every day at midnight (or whenever the least traffic occurs)

You'll also need these two code modifications:

in showthread.php find:

$query = $db->query("
			SELECT u.*, u.username AS userusername, p.*, f.*, eu.username AS editusername
			FROM ".TABLE_PREFIX."posts p
			LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
			LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid)
			LEFT JOIN ".TABLE_PREFIX."users eu ON (eu.uid=p.edituid)
			WHERE $pids
			ORDER BY p.dateline
		");

and replace with

$query = $db->query("
			SELECT u.*, u.username AS userusername, p.*, f.*, eu.username AS editusername, pp.parsedpost
			FROM ".TABLE_PREFIX."posts p
			LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
			LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid)
			LEFT JOIN ".TABLE_PREFIX."users eu ON (eu.uid=p.edituid)
			LEFT JOIN ".TABLE_PREFIX."parsedposts pp ON(pp.pid=p.pid)
			WHERE p.$pids
			ORDER BY p.dateline
		");

in inc/functions_post.php find

$post['message'] = $parser->parse_message($post['message'], $parser_options);

and replace with

if($mybb->user['already_parsed'] != 1)
{
	$post['message'] = $parser->parse_message($post['message'], $parser_options);
}
Interesting Tikitiki.

A quick scan, however - it seems that the parsed post cache is never updated when the message is parsed.

So basically, if the parsed post doesn't exist in the DB, MyBB will still continue to parse the post on-the-fly. This can be an issue with highly popular threads which will probably go over the expiration time.
Also, when updating parsing options, all parsed posts will have to be cleared, which is how you could loose some performance.
ZiNga BuRgA Wrote:Interesting Tikitiki.

A quick scan, however - it seems that the parsed post cache is never updated when the message is parsed.

So basically, if the parsed post doesn't exist in the DB, MyBB will still continue to parse the post on-the-fly. This can be an issue with highly popular threads which will probably go over the expiration time.
Also, when updating parsing options, all parsed posts will have to be cleared, which is how you could loose some performance.

Zinga there isn't an expiration date on popular threads. And yes, I'm aware of the clearing stuff. I haven't gotten around to it yet. As I stated before I won't be releasing these and these are simply for preview purposes or if your a coder you can take the code and properly expand it.
Sorry Tikitiki - it's just that since I've already made the modification, I expected another similar thing to have a number of distinct advantages. Apart from the fewer code edits, I don't particularly see an advantage using your modification over mine.

I guess it's still in development though, so I'll be quiet for now.
Pages: 1 2 3 4 5