Not Solved Preparser Cache (beta)
#1
Not Solved
Well, I've been meaning to make this for a while now, but never got around to it.
Anyways, this is a preparser cache plugin for MyBB.

This modification does a number of things:
  • Cache preparsed versions of posts.
  • Cache preparsed versions of signatures.
  • Hard replace topic titles (I personally see little reason why "soft"-copies should be kept...)

For those who may not understand what this does, basically, the parser is what turns MyCode into HTML. However, if you have a large number of smilies and/or custom MyCodes, the parser obviously has to do more work, replacing stuff in posts.
MyBB's parser is run every time someone views the post. That means, on a thread with about 10 posts, the parser has to go through 10 posts and parse each one.
This modification aims to lessen the load from the parser, by storing preparsed versions of posts in the DB.
How much this increases the speed of your board (primarily showthread.php) will depend probably on quite a number of factors.
I've tried to make this work as fast as possible though - preparsed messages are fetched via joins, so no extra queries are performed. Updates are performed via similar techniques as updates are performed in my MyPlaza plugin - all updates are cached, and committed to the DB via a single REPLACE INTO query (for each posts and signatures) at shutdown, to make things as fast as possible (and also won't break if the user cancels loading the page Toungue).

In this plugin, you can specify how long posts/signatures are kept in the cache.


I haven't had much chance to test this out, but it appears to be working fine here.

Due to the nature of how this works, a large number of code edits is required. Pre-edited MyBB 1.2.11 files are included for convenience.


Please feel free to ask any questions, report any bugs, provide suggestions or give any comments. Thanks!


Attached Files
.zip   preparser.zip (Size: 86.68 KB / Downloads: 163)
Reply
#2
Not Solved
This is a great idea. If I had a copy of MyBB installed....well anywhere.... I'd test it out, but I don't really know how I'd test it, or why I am trying to make a coherent post at 10:43PM...

Just ignore everything I said except the great idea thing..
Reply
#3
Not Solved
I'll probably try this out when I work on the backend of my forum in a few days.

I'll let you know how it goes. Smile
Avatar by Rein.
Reply
#4
Not Solved
it's a great idea I like it..
but what about storing the cache in the cache folder? in case u store your cache in the cache folder..
Official Arabic Translator.
Reply
#5
Not Solved
Have you done any actual test to compare speed and load?

Also what if a post is edited...does the cache get updated in real time?

Seems like a great idea to me to cache as much as possible but since so many file edits are required and we are so close to 1.4 I wonder if it is worth it. I would need to see test results to make up my mind.
Reply
#6
Not Solved
@labrocca for me I already tried to test it on my localhost.. but on localhost you can't feel the change of the speed becuas it's already running too fast..
Official Arabic Translator.
Reply
#7
Not Solved
pepotiger Wrote:it's a great idea I like it..
but what about storing the cache in the cache folder? in case u store your cache in the cache folder..
The main issue is the size of the cache. Caching a few thousand posts will obviously take up a lot of space.
MyBB's cache system doesn't work too well (from what I've seen) with large amounts of data. This may change with MyBB's new cache system.

labrocca Wrote:Have you done any actual test to compare speed and load?
No, because I really have limited time to test things out.
I'm almost certain that this will improve performance with lots of parser modifications. My main forum has a lot of smilies, MyCodes and badwords on it, and I currently do full preparsing. Full preparsing pretty much doubles the size of your posts table, but does reduce load significantly (showthread with 20 posts loads about 3 times faster).
A preparser cache is slightly more taxing (no table joins required), but nowhere near as much as doing full parsing.

labrocca Wrote:Also what if a post is edited...does the cache get updated in real time?
Obviously yes Toungue

labrocca Wrote:Seems like a great idea to me to cache as much as possible but since so many file edits are required and we are so close to 1.4 I wonder if it is worth it. I would need to see test results to make up my mind.
Close? I would expect 1.4 to be out, at the very earliest, at the end of this month.
This took me about 2 hours to write up, and I couldn't imagine it taking longer than 2 hours to make it work on 1.4, so meh.
Plus, just because you don't think it's worth it, doesn't mean I don't Wink
If you're not having any performance issues, then I see little reason why you should be interested in this at all.

And I can't provide much results as:
1) It's heavily dependant on your setup (ie MySQL server installed on localhost VS dedicated server, or lengths of posts, or number of smilies etc etc)
2) Don't have the time Toungue

This places a very minimal amount of additional load, so is unlikely going to make your board slower (apart from the parser doing the preparsing).

pepotiger Wrote:@labrocca for me I already tried to test it on my localhost.. but on localhost you can't feel the change of the speed becuas it's already running too fast..
You shouldn't be able the feel the change. Look at the page generation times.
Reply
#8
Not Solved
May I ask if you think the file core changes could be changed to in all one plugin?
Reply
#9
Not Solved
Tikitiki Wrote:May I ask if you think the file core changes could be changed to in all one plugin?
I don't think it's possible, well, without some speed loss Tikitiki.
The closest hook that happens before post parsing is probably showthread_start, which means that I'd practically have to copy most of showthread.php, then call exit() to stop the normal showthread from running.
I'd probably have to include a custom version of /inc/functions_post.php as well, so that it doesn't call up the parser.

It's possible, yes, however, would require changed files anyway, and would basically make most of showthread.php, inc/functions_post.php etc useless (plus you get the extra delay for the PHP parser to go through the files).

Do you have any ideas or suggestions?
Reply
#10
Not Solved
blueparukia Wrote:why I am trying to make a coherent post at 10:43PM...

You should see me code and post support at 2-3am in the morning Toungue It's much worse than 11pm.
Dennis Tsang
Former MyBB Team Member
Web: http://dennistt.net
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)