Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
[How to] Cut down on memory usage
Brad
Join Date: Nov 2001
Posts: 4,765

 

Show Printable Version Email this Page Subscription
Brad Brad is offline 01-05-2006, 10:00 PM

This is in the manual but I've yet to see it mentioned here.

Quote:
The plugin system works by storing all plugin code for all scripts in memory, so you can quickly find your plugins using large amounts of memory if they contain a lot of code.

A simple way to avoid this problem is to use the plugin code simply to call an external script, which contains all the complex code. In this way the code is only loaded when it is actually required.

For example, a plugin could contain this:
PHP Code:
$tmp_uid =& $vbulletin->userinfo['userid'];

$db->query_write("
  INSERT INTO " 
TABLE_PREFIX "profilelog
  (userid, dateline)
  VALUES
  (
$tmp_uid, " TIMENOW ")
"
); 
or alternatively, that code could be placed into a file called (for example) plugins/my_script.php, and the plugin itself would contain this:
PHP Code:
include('./plugins/my_script.php'); 
Naturally, the second option will use up far less memory than the first, and this saving will become more and more beneficial as the amount of code to be run increases.
You should also take a look at this project: https://vborg.vbsupport.ru/showthread.php?t=107315
Reply With Quote
  #22  
Old 04-08-2006, 08:43 PM
pmfp pmfp is offline
 
Join Date: Aug 2005
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have a problem with include's and phrases. It has been recreated in the files test.php and includes/test_include.php.

The problem is that the code is executed and the template fetched, but the phrase is not being printed. The nature of the real script means that I cannot use another plugin to insert the code, so that is out of the question.
Any ideas on how to do this properly?

test.php:
PHP Code:
<?php

error_reporting
(E_ALL & ~E_NOTICE);

define('THIS_SCRIPT''db_update');
$phrasegroups = array('test_phrases');

include(
'includes/test_include.php');

require_once(
'./global.php');

did_it();
?>
includes/test_include.php:
PHP Code:
<?php

function did_it() {
    
$varvar "set";
    
    eval(
'print_output("' fetch_template('test_splitter') . '");');
}
?>
test_splitter template:
HTML Code:
<tr>
<td width="310" valign="top" class="thead">
	<if condition="$varvar==set">$vbphrase[test_hello_world]</if>
</td>
<td valign="top" class="thead"></td>
</tr>
Reply With Quote
  #23  
Old 02-11-2007, 06:37 AM
thincom2000 thincom2000 is offline
 
Join Date: May 2006
Location: Bronx, NY
Posts: 1,205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I just added about 10 of my larger plugins to files, and I have noticed a considerable lag on the forum. Page generation times have increased from .10 seconds to 2 seconds or more, and server load has gone up from about 1.00 to anywhere from 8 - 40. 40!!!!!

EDIT: Looks like it was just a really bad night for server load. My forum seems to be running at the normal load today.
Reply With Quote
  #24  
Old 01-06-2008, 03:39 PM
Whissi Whissi is offline
 
Join Date: Jun 2005
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Do you still believe that outsourcing hugh plugins to includes will speed up your forum?
I don't think so. It sounds like it should improve the performance, but in real scenarios, it doesn't matter.

At least, have a look in the official addons like the blog software. They put their code in the plugins and not in files they include. They did it with high traffic hooks like fetch_userinfo... Haven't they thought about performance or doesn't that matter...
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:26 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05294 seconds
  • Memory Usage 2,239KB
  • Queries Executed 18 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_html
  • (4)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (3)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete