Preparser Cache
Author Message
This is a fairly simple pre-parser modification which should speed up one of MyBB's slowest functions.
Basically, MyBB's MyCode parser is rather slow; this plugin speeds this component up by caching the result so that the parser does not have to be run on every single page request (this is assuming that SHA1 hashing + a single query with some string manipulation is faster than running the parser 20+ times).

This plugin is compatible with all supported DB engines (SQLite in MyBB 1.6.0 is bugged, so cannot be tested).

Compatibility with other plugins
Due to the fact that this modification changes the environment under which the parser is run, I cannot guarantee that this will work with all MyCode/HTML or parser related plugins, especially those that may display posts differently to different users (on the other hand, this actually may have the potential to remove some of the issues in some poorly coded modifications).  Custom MyCodes should still work, and there is a workaround for the vB Quote plugin.
This will not work with the HTML in Posts plugin.

About design
The design of this is much simpler than my mod for MyBB 1.2, and as such, is nowhere near as aggressive, however, it's something I (originally!) banged up together in about an hour, and gets most of the benefits anyway.  It differs from both my 1.2 mod, and Ryan Gordon's 1.4 mod in that it operates at a parser level instead of at the showthread/postbit level.

The plugin only does posts and signatures on showthread.php, but it can be quite easily modified for other places, as it operates on a parser level.  Again, this was something I wrote fairly quickly, and could use a number of improvements in some areas.
The cache is periodically cleaned via a cleanup task.

Note
Note that this plugin also provides a way to manually clear the cache, under the Recount & Rebuild section of the AdminCP, should you ever have the need to do so.

Known Issues
  • Attachments embedded with the [attachment=id] code may not have their download count updated
  • A very minor one - it's possible to cause this plugin to display removed attachments embedded in the post (will be a dead link though).  Standard MyBB behavior will simply ignore the [attachment=id] code.  This will do the same if the post is updated in any way.
  • For MyBB 1.8, quote times will be forced to use absolute time (instead of relative).  For earlier versions, there is no change to the timestamp displayed, however the "Today" and "Yesterday" text will never get updated (until a cache clear), so this can be inaccurate if this occurs



Simple Benchmark
Just a simple benchmark I performed to get an idea of the speed gains of this plugin.  I'm benchmarking this page, with and without the plugin.  I guess the page is somewhat a good candidate for this plugin, although I didn't exactly cherry pick it on purpose.

Times were recorded by just using the time metric at the bottom of the page.  Note that the plugin does a number of things after the timer has completed, so I've also made a comparison after modifying MyBB's timer to more accurately measure the time (if you don't perform this modification, the preparser mod should pretty much always make your showthread pages seem to run faster).
Pages were loaded 3 times.

Standard behaviour: 0.2359838s, 0.2380810s, 0.2462718s
Standard behaviour, after editing timer: 0.2320759s, 0.2335730s, 0.2380040s
With preparser (with timer edit): 0.1327140s, 0.1319780s, 0.1258268s
With preparser (without timer edit (inaccurate)): 0.1291881s, 0.1186280s, 0.1211529s

Initial load with preparser, timer edit: 0.2454121s (this is the page load which caches everything - it'll be slower than normal page loads, but subsequent requests will be much faster)

1.0 benchmarks:
Standard behaviour: 0.2242870s, 0.2201211s, 0.2377510s
Standard behaviour, after editing timer: 0.2399340s, 0.2398720s, 0.2158720s
With preparser (with timer edit): 0.1303909s, 0.1500199s, 0.1303349s
With preparser (without timer edit (inaccurate)): 0.1157429s, 0.1143448s, 0.1083250s
(This post was last modified: 04-02-2017 10:23 PM by ZiNgA BuRgA.)
Find all posts by this user
Quote this message in a reply
Download: preparser-1.13.7z (4.52 KB)
Plugin Version: 1.13
Last Updated: 04-02-2017, 10:23 PM

Downloads: 1,873
MyBB Compatibility: 1.4.x, 1.6.x, 1.8.x
Plugin License: WTFPLv2
Uploader: ZiNgA BuRgA
Renegader Offline
Junior Member
**
Posts: 2
Joined: Jul 2011
Post: #31
RE: Preparser Cache
Not even with the newest MyBB? Maybe your server doesn't have the limits where it limits queries to 15 seconds, since I'm on a shared host?
08-01-2011 11:26 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #32
RE: Preparser Cache
It doesn't matter what the limits are because queries are taking nowhere near 15 seconds.
I don't have the latest MyBB but I'm doubting that's an issue.  You can try reinstalling the plugin to see if there's any effect.

If you can give a step by step reproduction guide from a clean forum install on how to reproduce, I can look into it, otherwise there's probably an issue with your server or setup.

My Blog
08-02-2011 08:01 AM
Find all posts by this user Quote this message in a reply
AglioEoliO Offline
Junior Member
**
Posts: 39
Joined: Jan 2008
Post: #33
RE: Preparser Cache
I´ve got several 'server 500' errors too, just after upgrading to 1.6.4 and disabling this plugin fixed the errors, Zinga

After the last upgrade the forum itself is pretty fast, but if it´s possible to make it compatible again is always good to have some performance tweak
08-02-2011 11:23 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #34
RE: Preparser Cache
I cannot reproduce any such issue on a localhost MyBB 1.6.4 install unfortunately.

My Blog
08-02-2011 03:56 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #35
RE: Preparser Cache
Tried doing a diff between some files from MyBB 1.6.1 and 1.6.4 but can't identify anything that'd particularly cause a 500 error.
If anyone can provide a step-by-step reproduction guide on how to do it, I can investigate, but otherwise, unfortunately, I can't figure out what the issue may be.

My Blog
08-04-2011 10:44 AM
Find all posts by this user Quote this message in a reply
Pirata Nervo Offline
Member
***
Posts: 235
Joined: Jan 2008
Post: #36
RE: Preparser Cache
How did I never notice this plugin? Great plugin Zinga! I'm going to install this one next Monday or Tuesday and will let you know if I get that error
08-06-2011 03:44 AM
Find all posts by this user Quote this message in a reply
Shemo Offline
Member
***
Posts: 184
Joined: Jan 2008
Post: #37
RE: Preparser Cache
Zinga,

some users are reporting some errors on my forum that appear to be caused by this plugin.  When disabling it, 1 user in particular stops seeing the error he was having, but after enabling it again, to confirm, the user immediately begins receiving the errors when trying to view a particular thread.

The error that has been reported is this error:
"[an error occurred while processing this directive]"

I posted about this on the community site here:
http://community.mybb.com/thread-103705.html

here's the initial help thread someone started on my forum:
http://damnfineshave.com/thread-why-do-i...http://damnfineshave.com/thread-why-do-i-keep-getting-th

and here's a thread where a forum user named "freddy" on my forum was continually having trouble viewing page 2:
http://damnfineshave.com/thread-gillette...http://damnfineshave.com/thread-gillette-7-o-clock-super-platinum

finally, here's a list of activated plugins on my forum:
Auto Media (1.1.9)
Contact Form (3.1)
Fit on Page (2.3)
Google Analytics (1.5)
MyBB GoMobile (1.0)
Goodbye Spammer (0.1.2)
Google SEO (1.6.1)
UserGroup Legend On Index (1.1)
* imei Page Optimizer! (1.0.1)
Login Password Conversion (1.0)
NotifyMovedThread Plugin! (0.1.1)
Show the users that has been online today (2.0)
PluginLibrary (4)
Registration Security Question (1.1)
Settings Cleaner (2.0)
Simple Captcha (1.6)
Trash Can Forum (2.0)
XThreads v1.46
(This post was last modified: 09-13-2011 08:37 AM by Shemo.)
09-13-2011 08:03 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #38
RE: Preparser Cache
I have no idea about that one.
Probably server configuration / host issue.

My Blog
09-13-2011 10:38 AM
Find all posts by this user Quote this message in a reply
Shemo Offline
Member
***
Posts: 184
Joined: Jan 2008
Post: #39
RE: Preparser Cache
hmn, I enabled this plugin on another forum I admin and some users are reporting the same "an error occurred while processing this directive" error when trying to go to the 2nd page of a thread.  both the current forum I admin and the other one I used to run and had this same error on were running on host monster's shared hosting.

any recent ideas, Zinga?
08-09-2012 01:59 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #40
RE: Preparser Cache
Nope.

My Blog
08-09-2012 02:37 PM
Find all posts by this user Quote this message in a reply


Forum Jump: