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,859
MyBB Compatibility: 1.4.x, 1.6.x, 1.8.x
Plugin License: WTFPLv2
Uploader: ZiNgA BuRgA
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #51
RE: Preparser Cache
Well, there is no point in having both installed at the same time...

My Blog
04-07-2015 05:15 PM
Find all posts by this user Quote this message in a reply
Shemo Offline
Member
***
Posts: 184
Joined: Jan 2008
Post: #52
RE: Preparser Cache
(04-07-2015 05:15 PM)ZiNgA BuRgA Wrote:  Well, there is no point in having both installed at the same time...

thanks, I installed this plugin.  so far, no errors!

Yipi
04-23-2015 04:55 PM
Find all posts by this user Quote this message in a reply
Sama34 Offline
Senior Member
****
Posts: 490
Joined: May 2011
Post: #53
RE: Preparser Cache
So I have this plugin which is meant to remove a tag from the first post message.
https://github.com/Sama34/OUGC-Show-in-P...https://github.com/Sama34/OUGC-Show-in-Portal/blob/master/Upload/inc/plugins/ougc_showinporta

How would you suggest to update my plugin to play nice with yours?

So far this is the only issue I found. Only idea that blows in my mind is something in pre_output_page.

Support PM's will be ignored. Yipi
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
05-02-2015 06:56 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #54
RE: Preparser Cache
This plugin, in general, doesn't work well if you need dynamic content, since it assumes posts are pretty much always the same.
To be quite honest, it does a pretty ugly hack to get things to work.  I'm inclined to say you're SOL.

But I suppose if you want to make it compatible, it might be possible to do your replacements before the parser runs (and this mod starts trashing the post) - probably hard though.

Perhaps I could make changes to make it play nicer with plugins - I never originally thought about it.

My Blog
(This post was last modified: 05-04-2015 09:40 PM by ZiNgA BuRgA.)
05-04-2015 09:21 PM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #55
RE: Preparser Cache
I have been using this plugin and it works fine - except for the quote dateline in posts - it doesnt update, so the dateline in the cite block is frozen to the relative time date of the quoted post at the time of quoting.

I looked in your plugin file and it has a workaround for the VB quote (looks to see if a plugin is running a pre_output hook) but I am using the MyBB 1.8 default quote.  

Would you consider updating this plugin for the MyBb relative time quote?


[Image: leelink.gif]
MYBB1.6 & XThreads
10-21-2015 10:06 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #56
RE: Preparser Cache
Thanks for pointing that out.
I'll add it to the list of things to consider.

My Blog
10-29-2015 01:20 PM
Find all posts by this user Quote this message in a reply
devnet Offline
Junior Member
**
Posts: 5
Joined: Feb 2016
Post: #57
RE: Preparser Cache
Hello,
The modification makes my problems Hide until reply plugin links are visible to everyone when you stop everything works normally.
The other which is - like himself rubs hour of css file.

Is there a solution is these two problems?
02-22-2016 11:34 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #58
RE: Preparser Cache
It will generally be problematic with parser modifications because this plugin changes how the parser operates.
I don't know what you mean in your second problem.

Ultimately, this plugin isn't required and provides no new functionality, so if it doesn't work, just remove it.

My Blog
02-23-2016 09:26 AM
Find all posts by this user Quote this message in a reply
devnet Offline
Junior Member
**
Posts: 5
Joined: Feb 2016
Post: #59
RE: Preparser Cache
(02-23-2016 09:26 AM)ZiNgA BuRgA Wrote:  It will generally be problematic with parser modifications because this plugin changes how the parser operates.
I don't know what you mean in your second problem.

Ultimately, this plugin isn't required and provides no new functionality, so if it doesn't work, just remove it.

Is there any possibility to hide all links from guests with a mod/editing code ??? I tried a few modifications and none works ....
02-23-2016 08:43 PM
Find all posts by this user Quote this message in a reply
devnet Offline
Junior Member
**
Posts: 5
Joined: Feb 2016
Post: #60
RE: Preparser Cache
Anyone??
03-01-2016 06:58 PM
Find all posts by this user Quote this message in a reply


Forum Jump: