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
  #12  
Old 02-03-2006, 07:06 PM
99SIVTEC 99SIVTEC is offline
 
Join Date: Nov 2001
Posts: 281
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just having the plugin system turned on uses extra queries. A good programmer ca hack vbulletin in such a way as to add few if any extra queries, but the system itself is what adds the extra queries.

Quote:
Originally Posted by MarcoH64
If coded for saving memory(ie. 99% of executable code in include files), a plugin don't need to use much memory, nor does it need to use more queries or slow down significantly.
Reply With Quote
  #13  
Old 02-03-2006, 07:10 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by 99SIVTEC
Just having the plugin system turned on uses extra queries. A good programmer ca hack vbulletin in such a way as to add few if any extra queries, but the system itself is what adds the extra queries.
Not sure on the exact amount of added queries when the plugin system is turned on, but it is not much, and they are good optimiyed and won't effect your board much from a performance point of view.

Remember that the number of queries is almost irrelevant for performance, it is the execution time that counts.
Reply With Quote
  #14  
Old 02-03-2006, 07:21 PM
PennylessZ28 PennylessZ28 is offline
 
Join Date: Mar 2002
Location: North America
Posts: 737
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Seems to me that just putting the plugin code in a php file and replacing it with

include('./plugins/my_script.php');

Doesn't work 100%
Reply With Quote
  #15  
Old 02-03-2006, 07:45 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nobody ever said that things would work without any modification.
Reply With Quote
  #16  
Old 02-03-2006, 07:57 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

1. Turning the Plugin System On or Off does not have any impact on the amout of queries.
2. Memory Footprint is not a such a big issue. In most cases, forumcache (which is loaded on every page) for example will be a lot bigger then the plugins.

Having to eval() the code all the time, that is an issue.

Therefore, complex plugin code (especially in high-traffic places like global.php, postbit, showthread, forumdisplay, etc.) should be moved out to include files.
(Could even be done automatically. I wrote a proof-of-concept hack that writes include-files if the plugin-code on one hook is > X bytes long.)
Reply With Quote
  #17  
Old 02-03-2006, 07:59 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by HR3rdGen
Seems to me that just putting the plugin code in a php file and replacing it with

include('./plugins/my_script.php');

Doesn't work 100%
Hmm ... what problems did you have?

If you use
PHP Code:
include(DIR '/plugins/my_script.php'); 
it should work 100%.
Reply With Quote
  #18  
Old 02-03-2006, 11:17 PM
PennylessZ28 PennylessZ28 is offline
 
Join Date: Mar 2002
Location: North America
Posts: 737
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Andreas
Hmm ... what problems did you have?

If you use
PHP Code:
include(DIR '/plugins/my_script.php'); 
it should work 100%.
I converted two plugins to test this. VBSHOUT for one, which failed 100%.

And then estakis referral stats. That one works, half way.

It's depositing all the code in raw format on the page.

Crazy I tell ya.
Reply With Quote
  #19  
Old 02-03-2006, 11:22 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Erm ... are you sure you put

Code:
<?php
// Plugin Code here
?>
in the files?
Reply With Quote
  #20  
Old 02-03-2006, 11:57 PM
PennylessZ28 PennylessZ28 is offline
 
Join Date: Mar 2002
Location: North America
Posts: 737
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Andreas
Erm ... are you sure you put

Code:
<?php
// Plugin Code here
?>
in the files?
Yes I'm stupid. I forgot that. LMAO
Reply With Quote
  #21  
Old 02-09-2006, 08:20 PM
Trigunflame's Avatar
Trigunflame Trigunflame is offline
 
Join Date: Aug 2002
Posts: 742
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Solution to all your problems

https://vborg.vbsupport.ru/showthread.php?t=107315
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 10:57 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.05236 seconds
  • Memory Usage 2,307KB
  • Queries Executed 25 (?)
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
  • (2)bbcode_code
  • (4)bbcode_php
  • (6)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
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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