vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Graveyard (https://vborg.vbsupport.ru/forumdisplay.php?f=224)
-   -   Board Optimization - Plugin Based Template Cache (https://vborg.vbsupport.ru/showthread.php?t=121876)

Zia 03-09-2007 03:23 PM

Quote:

Originally Posted by Xplorer4x4 (Post 1198194)
I am using 1.0.3

what are u using as cacher ? APC?

orban 03-09-2007 05:46 PM

Quote:

Originally Posted by Xplorer4x4 (Post 1196162)
I have chmodded my folder to 777 but it refuses to write there. Only to the root.

Well, it automatically clears the template folder so if the cache does not get written into that folder then it won't get cleared.

I really have no idea why it doesn't work, maybe ask your host if they have any special setup?

Xplorer4x4 03-09-2007 05:51 PM

Quote:

Originally Posted by Zia (Post 1199572)
what are u using as cacher ? APC?

Just this.
Quote:

Originally Posted by orban (Post 1199652)
Well, it automatically clears the template folder so if the cache does not get written into that folder then it won't get cleared.

I really have no idea why it doesn't work, maybe ask your host if they have any special setup?

Special setup as in php cache systems like APC XCache and eaccelerator?

orban 03-09-2007 05:54 PM

That shouldn't affect PHPs writing capabilities :/

Zia 03-10-2007 07:36 AM

helo Xplorer..

umm u can have a try to use another cacher rather than APC.

Zia 03-10-2007 08:11 AM

Quote:

Originally Posted by da420 (Post 1198144)
This happens to me sometimes too.

When I go into make template edits I just disable this modification. Then once I am done, I re-enable it, and alls well....

if ur on Xcache. u have to turn on
xcache.stat = on

if u set it off. it wont work.

Zia 03-10-2007 08:13 AM

Orban,
Helo..
can u say whats the difference between urs hack (this thread) & This One

both is template cacher..really very much confused..
this 2 can be use together?
(maybe ur on Xcache.im on xcache too)

Thanks

amcd 03-10-2007 08:41 AM

Quote:

Originally Posted by Zia (Post 1200048)
Orban,
Helo..
can u say whats the difference between urs hack (this thread) & This One

both is template cacher..really very much confused..
this 2 can be use together?
(maybe ur on Xcache.im on xcache too)

Thanks

From a quick read it seems that one tries to cache templates in the variable space of the php opcode cacher (APC/xcache/other), whereas orban's tries to create php files out of the templates, so that they get cached automatically by the cacher.

If properly implemented, both should give similar benefits, but IMHO the other one needs some more work to become fully stable. Even after that, new users will continue to face problems because by default the opcode caching programs have the variable memory disabled.

orban 03-10-2007 09:33 AM

I don't think it avoids eval calls like mine does (which is the whole point of mine). It just saves the templates in the variable cache of apc/xcache/eac/mmcache and does some compressing. I also doubt they work together (mine will just overwrite his other the other way around).

You can't avoid the eval call unless you write the templates to files.

Zia 03-10-2007 11:21 AM

Hi amcd,
Yes i noticed ,im on Xcache.the other one caching things at var. portion & didnt cache anything at php portion. at my end i have enabled var.cache using This
which is relased by mOo aka phpxcache.

Orban, finally other one tries to cache thing at var.cache instead of php cache and urs one cache to phpcache but the moto is allmost same ? just the way is difference ??
do u have any suggetions ?

compress is diff.template compression always create probs as well.

orban 03-10-2007 11:30 AM

That modification released by mOo is nice, I'm using memcached though, but in the end it's basically the same thing.

Yeah compressing templates always causes problems.

I know, the newly released template cache by lendy just caches the templates in a variable cache. You won't save any eval() calls by doing this, you won't even avoid the unserialize as far as I know (just took at a quick glance at his code).

amcd 03-10-2007 01:21 PM

oh, I never thought about the evals. Yes, you are right. He cannot avoid evals by caching templates in variables.

Regarding the datastore, I installed memcache, but later went back to file because I could not notice any difference. Is there a way to benchmark the datastore?

orban 03-10-2007 01:25 PM

Well you could probably write a script to read the datastore objects 1000 times from memcached and flat files (cached in APC) and from APC var cache and see how fast it is :)

Frames 03-10-2007 01:46 PM

Hi, more info:

Without your plugin mysql use: 60 mb/sec

With your plugin mysql use: 30 mb/sec

Thanks!!!!!

Zia 03-10-2007 04:12 PM

Quote:

Originally Posted by amcd (Post 1200190)
oh, I never thought about the evals. Yes, you are right. He cannot avoid evals by caching templates in variables.

Regarding the datastore, I installed memcache, but later went back to file because I could not notice any difference. Is there a way to benchmark the datastore?

using that data store(xcache + its datastore cache)...
it straight reduce 2 more query at my forum home..
rcade home..it reduce 5 call...
so i think in other pages it also reduced....
yes forum got more smoother

Xplorer4x4 03-10-2007 04:32 PM

Quote:

Originally Posted by Zia (Post 1200030)
helo Xplorer..

umm u can have a try to use another cacher rather than APC.

Huh? I am not using nay other caches with this.

bluechris 03-10-2007 11:37 PM

I have a problem since i installed it.... suddenly the forum index shows a strange error

Quote:

Warning: Unterminated comment starting line 151 in C:\Domains\corollaclub.com\wwwroot\forums\forums.p hp(539) : eval()'d code on line 151
the line 151 in forums.php is this

Quote:

if ($vbulletin->options['showevents'])
Forums.php is the normal index.php that vb has but i had renamed it and i have index the cmps.

The thing is that the code in the file is fine.... even though i had replaced it with the latest and i still getting the error.

I had also uninstalled the addon with no luck...... I am with IIS6 .. php 4.4.6 with apc and mysql 4.1.16.

Anyone has any clue?

amcd 03-11-2007 08:55 AM

your error is on line 151 of the template which is called from line 539 of forums.php

bluechris 03-11-2007 10:41 AM

But i havent touched something.....

the lines in forumhome template are

Quote:

148 <!-- icons and login code -->
149 <table cellpadding="0" cellspacing="2" border="0" width="100%">
150 <tr valign="bottom">
151 <td>
152 <table cellpadding="2" cellspacing="0" border="0">
and in forums.php the 539 line is

Quote:

($hook = vBulletinHook::fetch_hook('forumhome_complete')) ? eval($hook) : false;
I even created a new style with no parent (that supposes will have the default templates) and i get the same error.... atm i have puted in php.ini showerrors to off and i dont see it but its a problem. Is there anyway that i can debug more the error? to be more specific i mean?

amcd 03-11-2007 10:47 AM

Line 539 is evaluating a hook, so look in your plugins, not in the template.

See which plugins are being executed on 'forumhome_complete'. One of them probably has a opening /* but no closing */

dbirosel 03-12-2007 04:36 PM

reserved!!

orban 03-12-2007 05:03 PM

Quote:

Originally Posted by bluechris (Post 1200525)
I have a problem since i installed it.... suddenly the forum index shows a strange error



the line 151 in forums.php is this



Forums.php is the normal index.php that vb has but i had renamed it and i have index the cmps.

The thing is that the code in the file is fine.... even though i had replaced it with the latest and i still getting the error.

I had also uninstalled the addon with no luck...... I am with IIS6 .. php 4.4.6 with apc and mysql 4.1.16.

Anyone has any clue?

Are you using the experimental version?

Quote:

Originally Posted by dbirosel (Post 1201702)
reserved!!

Pardon?

Zia 03-13-2007 04:28 AM

helo orban,

here its ur experiemntal one ?
https://vborg.vbsupport.ru/showpost....&postcount=242

i got spaces for using it...but could u plese be more specific...or can u just make the function.php or whatever.php files here .. i want to go for it..if it give more output......

Looking for ur help.
Thnx.

GrendelKhan{TSU 03-16-2007 12:19 PM

woot

|Jordan| 03-18-2007 12:33 AM

Where can i get the opcode cache plugin?

Zia 03-18-2007 06:22 AM

Quote:

Originally Posted by |Jordan| (Post 1205956)
Where can i get the opcode cache plugin?

do u have any opcode cacher installed ?
like Xcache /eAcc or APC ?

Orban's mod will boost cacher....


if ur on xcache u can also try IT

orban 03-18-2007 09:20 AM

Quote:

Originally Posted by |Jordan| (Post 1205956)
Where can i get the opcode cache plugin?

Sorry, what do you mean?

You don't need any vBulletin modification to run APC/aAccelerator/xcache.

Zia 03-18-2007 12:24 PM

Quote:

Originally Posted by orban (Post 1157214)
EXPERIMENTAL (for your dev board)

This will NEVER work with plugins who modify templates on run time so don't even try :)

Place the function in a file & create forums/cache folder

Code:

function cache_templates_one_file($templates, $templateidlist)
{
        global $vbulletin, $templateassoc;

        if (empty($templateassoc))
        {
                $templateassoc = unserialize($templateidlist);
        }

        if ($vbulletin->options['legacypostbit'] AND in_array('postbit', $templates))
        {
                $templateassoc['postbit'] = $templateassoc['postbit_legacy'];
        }
       
        foreach ($templates AS $template)
        {
                $templateids[] = intval($templateassoc["$template"]);
        }

        /* THE ACTUAL PLUGIN */
        $templatefile = 'cache/'.md5(implode(',', $templateids)).'.php';
        if (file_exists($templatefile))
        {
                include($templatefile);
        }
        else
        {
                $templatecache = '';
        /* END ACTUAL PLUGIN */
                // run query
                $temps = $vbulletin->db->query_read("
                        SELECT templateid, title, template
                        FROM " . TABLE_PREFIX . "template
                        WHERE templateid IN (" . implode(',', $templateids) . ")");
                // cache templates
                while ($temp = $vbulletin->db->fetch_array($temps))
                {
                        /* START ACTUAL PLUGIN */
                        preg_match_all('/\$[a-zA-Z][a-zA-Z\_0-9]+/', $temp['template'], $out);
                        $vars = array_unique($out[0]);
                        $templatecache .= '
                                /* '.$temp['title'].' */ $template_vars['.$temp['templateid'].'] = \''.implode(', ', $vars).'\'; function template_'.$temp['templateid'].'('.implode(', ', $vars).') { return "'.$temp['template'].'"; } ';
                        /* END ACTUAL PLUGIN */
                }
                $vbulletin->db->free_result($temps);
                /* START ACTUAL PLUGIN */
                $fp = fopen($templatefile, 'w+');
                if ($fp && flock($fp, LOCK_EX))
                {
                        fwrite($fp, '<?php '.$templatecache.' ?>');
                        flock($fp, LOCK_UN);
                        fclose($fp);
                }
                include($templatefile);
                /* END ACTUAL PLUGIN */
        }

        foreach ($templates AS $template)
        {
                if (substr($template, 0, 17) == 'editor_jsoptions_' or substr($template, 0, 14) == 'editor_styles_')
                {
                        $vbulletin->templatecache[$template] = call_user_func('template_'.intval($templateassoc["$template"]));
                }
                else $vbulletin->templatecache[$template] = '".template_'.intval($templateassoc["$template"]).'('.$template_vars[intval($templateassoc["$template"])].')."';
                #$vbulletin->templatecache[$template] = '';
        }
       
        $vbulletin->bbcode_style = array(
                'code'  => &$templateassoc['bbcode_code_styleid'],
                'html'  => &$templateassoc['bbcode_html_styleid'],
                'php'  => &$templateassoc['bbcode_php_styleid'],
                'quote' => &$templateassoc['bbcode_quote_styleid']
        );
}

And call it in "cache_templates" hook (adjust the path for the file with the function in it)

Code:

include('includes/functions_hooks.php');
cache_templates_one_file($globaltemplates, $style['templatelist']);
$globaltemplates = array();

does not delete cache when modifying templates and no options in it, please

ONLY USE THIS IF YOU KNOW WHAT YOU ARE DOING and understand the code

It basically reads all templates and creates a function for every template with all the variables in it passed as arguments so you can avoid scope issues.

Please note this takes up A LOT of space in xcache/APC (about 40mb for the cache/ files alone) so make sure you have enough space allocated (I'm using 128mb atm and that works fine).

Again please don't install this if you don't know PHP well and know what you're doing. Just sharing this because I've been using it for a few days successfully and maybe somebody can use it. :) This mod doesn't modify the database or any vB files (like the version you can download).

Orban,could u please help a bit more about it...

orban 03-18-2007 12:32 PM

I just don't have the time right now to support this thing (I mean check the number of pages in this thread, and the experimental is indeed experimental and there's several issues to be worked out).

Zia 03-18-2007 12:40 PM

ah ha..Okay..
just thought it might be good than the existing one...so wanted to give a try....

Okay....but like this existing mods "boost up php cache" for any opcode cacher...
is there any way to boost up var.cacher ?

amcd 03-18-2007 12:42 PM

Disable the original plugin based template cache. Under your forums, create a new folder called 'cache' and make sure it is writable by the webserver user (www or nobody or similar).

Copy everything in the first code block and put it in a new php file. Save it as yourforums.com/forums/includes/functions_hooks.php

Then, in your adminCP, open 'Add a new plugin'. Under hook location, select 'cache templates'. Under 'Plugin PHP code', put everything from the second code block in orban's post. Make sure 'active' is yes, give it a descriptive name like 'Orban's experimental template cache' and save it.

That's it.

If you ever make any changes to your templates, you have to manually delete forums/cache/*.php otherwise your template changes will not become active.

If this interferes with any other plugin, then there is no remedy as of now. You have to either stop using the other plugin or go back to the old cache.

Zia 03-18-2007 12:51 PM

thnx amcd..

seemd it will create probs (as Orban said). But does it make it any better than the existing one?

amcd 03-18-2007 12:59 PM

It 'may' create problems, not 'will'. It is unsupported. So you can use it if you are confident or daring.

Don't listen to me, because if something bad happens, I may not be competent to help you. It is orban's creation, and if he says it is experimental and not fit for production boards, I guess it is not. But I am using it without any problems from the day he first posted it.

edit: The only reason I am subtly urging you to use it is that I want more people to use it. That will probably put pressure on orban to develop it into a more mature solution. :)

Zia 03-18-2007 04:44 PM

Quote:

Originally Posted by amcd (Post 1206350)
edit: The only reason I am subtly urging you to use it is that I want more people to use it. That will probably put pressure on orban to develop it into a more mature solution. :)

hahaah i believe u read my mind :P
more user more pressure developed version

what r u using as opcode cacher ? how many ram did u allocate for that?

what s ur experience about perfoamance gaining ?

amcd 03-18-2007 05:24 PM

I am using xcache with lighttpd. I have allocated more, but 128 MB should be more than enough if you only have vbulletin.

Regarding performance gains, let us just say that I cannot imagine my forums running without xcache or this plugin. Come to think of it, I cannot imagine my forums running on apache.

btw, if you are really looking for big performance gains and have some php/mysql knowledge, do try sphinx search. The sphinx implementation for vbulletin is also orban's creation, and it is just unbelievable to say the least.

Zia 03-19-2007 12:29 PM

ah i think yet pit forum is not in the shape to impliment sphinx search.yes i read the whole thread for sphinx by orban.Still we are not that large in size....even not in bigboards
just saw ur board...do u mind to say ur server configuration ? dedicated ?

but soon will install the new experimental one...maybe tomorrw night.....
we got 320MB Ram + 1Gb burst ram. 128MB wont be a problem for us.

amcd 03-23-2007 11:22 AM

I am using the experimental version. Since yesterday our users were reporting few problems. The php error logs show a lot of these errors.

Code:

Call to undefined function template_4789() in /usr/home/xb/www/bbb/includes/functions.php(4605) : eval()'d code on line 1
line 4605 of functions.php calls the template called 'option'. I even tried adding a line to the beginning of the plugin, but it did not help. The line I put in was

globaltemplates[] = 'option';

orban 03-23-2007 01:38 PM

Have you recently installed an addon?

You can also try to exclude it, it's somewhere in the function....like I excluded the css templates.

amcd 03-23-2007 01:42 PM

no, I have not installed any add-on.

I have gone back to the original mod for now, and it seems to be working fine.

orban 03-23-2007 05:06 PM

You could try to add "option" to

if (substr($template, 0, 17) == 'editor_jsoptions_' or substr($template, 0, 14) == 'editor_styles_')

or $template == 'option'

Or check what exactly is wrong on that line of code so I can maybe give you a fix...


All times are GMT. The time now is 11:34 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01846 seconds
  • Memory Usage 1,854KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (18)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete