• Register
    • Help

    striker  0 Items
    Currently Supporting
    • Home
    • News
    • Forum
      • Try XenForo Demo
      • New Posts
      • FAQ
      • Calendar
      • Community
        • Groups
        • Albums
        • Member List
      • Forum Actions
        • Mark Forums Read
      • Quick Links
        • Today's Posts
        • Who's Online
      • Sponsor
        • Sponsor a Feature
        • List of Donors
    • Wiki
    • Support
    • What's New?
    • Buy Now
    • Manual
    • 
    • Forum
    • VaultWiki How-Tos
    • VaultWiki Questions
    • Article page load spending 1.4 seconds doing PHP things.

    1. Welcome to VaultWiki.org, home of the wiki add-on for vBulletin and XenForo!

      VaultWiki allows your existing forum users to collaborate on creating and managing a site's content pages. VaultWiki is a fully-featured and fully-supported wiki solution for vBulletin and XenForo.

      The VaultWiki Team encourages you to join our community of forum administrators and check out VaultWiki for yourself.

    Results 1 to 11 of 11

    Thread: Article page load spending 1.4 seconds doing PHP things.

    • Thread Tools
      • Show Printable Version
    1. December 20, 2010 #1
      Alfa1
      • View Profile
      • View Forum Posts
      • View Blog Entries
      • View Articles
      Alfa1 is offline
      Distinguished Member
      Join Date
      September 26, 2007
      Posts
      584
      Rep Power
      257

      Article page load spending 1.4 seconds doing PHP things.

      When looking at my VW articles in debug mode, I find that there is quite a difference between articles in loading time. Its not the queries, as they are mostly quick. One of my most viewed articles (50.000 views) gives this result:

      Page generated in 1.48419094086 seconds with 45 queries, spending 0.0618517398834 doing MySQL queries and 1.42233920097 doing PHP things.
      Do you know what causes this?
      Reply With Quote Reply With Quote

    2. December 21, 2010 #2
      pegasus
      • View Profile
      • View Forum Posts
      • View Blog Entries
      • Visit Homepage
      • View Articles
      pegasus is offline
      VaultWiki Team
      Join Date
      March 28, 2004
      Location
      New York, NY
      Posts
      2,934
      Blog Entries
      18
      Rep Power
      659
      Did you find the issue? All of the pages on your site are taking less than a second for PHP, and most articles are taking less than .2 seconds.
      - lead developer for VaultWiki
      Reply With Quote Reply With Quote

    3. December 21, 2010 #3
      Alfa1
      • View Profile
      • View Forum Posts
      • View Blog Entries
      • View Articles
      Alfa1 is offline
      Distinguished Member
      Join Date
      September 26, 2007
      Posts
      584
      Rep Power
      257
      Not yet. Its not server strain.
      Last night my server load was going trough the roof(54!) and my site became unreachable. There where only 6.500 users, while 10k users is normally doing OK.
      Today server load is normal again and php page load is still 1.4 seconds
      Reply With Quote Reply With Quote

    4. December 21, 2010 #4
      pegasus
      • View Profile
      • View Forum Posts
      • View Blog Entries
      • Visit Homepage
      • View Articles
      pegasus is offline
      VaultWiki Team
      Join Date
      March 28, 2004
      Location
      New York, NY
      Posts
      2,934
      Blog Entries
      18
      Rep Power
      659
      This slowdown occurs because the longer an article is and the number of BB-Codes used make auto-link discovery more difficult. We intend to add an option to disable auto-links on a per-article basis, but not until VaultWiki 4.

      I have devised this, which will improve auto-link speed by about 50%, but I cannot speak to the accuracy of the discovery mechanism after this change. Only time and testing will tell. I don't think it's possible to improve the speed much more without serious repercussions to accuracy (i.e. creating links where links don't belong).

      In vault/class/bbcode/autolink.php, replace the complete
      Code:
      function process
      (Everything until the next function definition) with:
      Code:
      	function process($text, $parent, $use_html = false)
      	{
      		global $vbulletin, $vault;
      
      		$pregfind = array();
      		$pregreplace = array();
      		$wiki_links = array();
      
      		$force_return = false;
      
      		if (
      			$parent == CATEGORY_SPACE OR
      			$parent == IMAGE_SPACE OR
      			$parent == TEMPLATE_SPACE
      		)
      		{
      			$force_return = true;
      		}
      
      		if (!$force_return)
      		{
      			$vault->fetch_instance('article');
      
      			if (!$vault->article->fetch('autolinks', $parent, VAULT_LANGUAGEID, 'count'))
      			{
      				$force_return = true;
      			}
      		}
      
      		if (!$force_return)
      		{
      			$this->init_tags();
      			$preg_no_auto = array();
      
      			if (!empty($this->skip_tags))
      			{
      				$preg_no_auto[] = '#\[(' . implode('|', $this->skip_tags) . ')\].*\[/\1\]#siUe';
      			}
      
      			$preg_no_auto[] = '#\[[^\[]*\]#sUe';
      
      			if ($use_html)
      			{
      				$preg_no_auto[] = '#<(a|script|code).*</\1>#siUe';
      				$preg_no_auto[] = '#<.*>#sUe';
      			}
      
      			if ($vbulletin->options['vault_legacy_enabled'] == 1)
      			{
      				$preg_no_auto[] = '#\{.*(\||\})#sUe';
      			}
      		}
      
      		($hook = vBulletinHook::fetch_hook('vault_autolinks_start')) ? eval($hook) : false;
      
      		if ($force_return)
      		{
      			return $text;
      		}
      
      		global $post;
      		static $redirects_to_skip;
      
      		$articles_to_skip = $vault->parser['autolink_articles_to_skip'];
      		$matching_articles = array();
      		$text = htmlspecialchars_uni($text);
      
      		$vault->fetch_instance('string');
      		$lowertext = $vault->string->tolower($text);
      
      		// empty this in case we somehow parse multiple articles on the same page
      		$vault->parser['autolink_articles_to_skip'] = array();
      		$linkids = $vault->article->fetch('autolinks', $parent, VAULT_LANGUAGEID, 'dump');
      		$entities = get_html_translation_table(HTML_ENTITIES);
      
      		if ($vbulletin->options['vault_autolink_stop'])
      		{
      			$ignore_list = preg_split('#[\r\n]+#s', $vault->string->tolower($vbulletin->options['vault_autolink_stop']), -1, PREG_SPLIT_NO_EMPTY);
      		}
      
      		if (empty($ignore_list))
      		{
      			$ignore_list = false;
      		}
      
      		// turn on UTF-8 mode?
      		$vault->fetch_instance('language');
      		$langid = $vault->language->get(0);
      		$modifiers = 'iU';
      
      		if ($vault->language->charset["$langid"] == 'U')
      		{
      			$modifiers .= 'u';
      		}
      
      		foreach ($linkids AS $linkid => $linktitle)
      		{
      			$linktitle = $linktitle[VAULT_LANGUAGEID];
      
      			if (!$linktitle)
      			{
      				continue;
      			}
      
      			$linktitle = $vault->string->tolower($linktitle);
      
      			if (
      				strlen($linktitle) < $vbulletin->options['vault_autolink_min'] OR
      				$linktitle == 'ces' OR
      				$linktitle == 'dol' OR
      				$linktitle == 'xst' OR
      				$linktitle == 'l' OR
      				$linktitle == 'autolink' OR
      				intval($linktitle) > 0 OR
      				(
      					$ignore_list AND
      					in_array($linktitle, $ignore_list)
      				) OR
      				strpos($lowertext, $linktitle) === false OR
      				(
      					in_array($linktitle, $entities) OR
      					(
      						$number = str_replace(array('#', 'x', 'u', ';'), '', $number) AND
      						intval($number) > 0
      					)
      				)
      			)
      			{
      				continue;
      			}
      
      			$matching_articles[strlen($linktitle)]["$linkid"] = preg_quote($linktitle, '#');
      		}
      
      		krsort($matching_articles);
      		$text = str_replace('$', '#!#CES-XST()DOL#L', $text);
      		$text = preg_replace($preg_no_auto, '\$this->save("\0")', $text);
      
      		if (
      			!empty($linkids) AND
      			!empty($articles_to_skip) AND
      			VAULT == 'true' AND
      			empty($redirects_to_skip[$post['threadid']])
      		)
      		{
      			$redirects_to_skip[$post['threadid']] = array();
      
      			$redirects = $vbulletin->db->query_read_slave("
      				SELECT thread.threadid
      				FROM " . TABLE_PREFIX . "thread AS thread
      				LEFT JOIN " . TABLE_PREFIX . "vault_link AS link ON (thread.firstpostid = link.postid)
      				WHERE thread.threadid IN (" . implode(',', array_keys($linkids)) . ")
      					AND link.redirect = 1
      					AND link.targetid IN (" . implode(',', array_keys($articles_to_skip)) . ")
      				GROUP BY thread.threadid
      			");
      
      			if ($vbulletin->db->num_rows($redirects))
      			{
      				while ($redirect = $vbulletin->db->fetch_array($redirects))
      				{
      					$redirects_to_skip[$post['threadid']][$redirect['threadid']] = $redirect['threadid'];
      				}
      				$vbulletin->db->free_result($redirects);
      				unset($redirect);
      			}
      			else
      			{
      				$redirects_to_skip[$post['threadid']] = true;
      			}
      		}
      
      		if (is_array($redirects_to_skip[$post['threadid']]))
      		{
      			// numerical keys aren't preserved with array_merge
      			foreach ($redirects_to_skip[$post['threadid']] AS $redkey => $redval)
      			{
      				$articles_to_skip["$redkey"] = $redval;
      			}
      		}
      
      		$i = 0;
      		$totallen = 0;
      		$search = array();
      
      		foreach ($matching_articles AS $article_group)
      		{
      			foreach ($articles_to_skip AS $linkid => $ditto)
      			{
      				unset($article_group["$linkid"]);
      			}
      
      			if (empty($article_group))
      			{
      				continue;
      			}
      
      			$search = array_merge($search, $article_group);
      		}
      
      		if (!empty($search))
      		{
      			$searchstring = '#((?:^|[^\&\w]){1})(' . implode('|', $search) . ')((?:$|[^\w]){1})#' . $modifiers;
      			$text = preg_replace($searchstring, "\\1[AUTOLINK]\\2[/AUTOLINK]\\3", $text);
      		}
      
      		$text = $this->save('', $text, 1);
      		$text = str_replace('#!#CES-XST()DOL#L', '$', $text);
      		$text = unhtmlspecialchars($text);
      
      		return $text;
      	}
      - lead developer for VaultWiki
      Reply With Quote Reply With Quote

    5. December 21, 2010 #5
      Alfa1
      • View Profile
      • View Forum Posts
      • View Blog Entries
      • View Articles
      Alfa1 is offline
      Distinguished Member
      Join Date
      September 26, 2007
      Posts
      584
      Rep Power
      257
      Is there a possibility to set a maximum of 1 instance per autolink per page?
      If not, then I really think this should be added.
      Reply With Quote Reply With Quote

    6. December 21, 2010 #6
      pegasus
      • View Profile
      • View Forum Posts
      • View Blog Entries
      • Visit Homepage
      • View Articles
      pegasus is offline
      VaultWiki Team
      Join Date
      March 28, 2004
      Location
      New York, NY
      Posts
      2,934
      Blog Entries
      18
      Rep Power
      659
      The maximum you speak of is automatically applied, but not at the discovery level. Believe it or not, filtering during discovery takes longer than just discovering all locations and then ignoring duplicates.

      In my previous post, I was talking about the accuracy of auto-links being created where they shouldn't, like inside code blocks, noparse sections, or links that were explicitly made, or auto-link matches not being discovered where they should.
      - lead developer for VaultWiki
      Reply With Quote Reply With Quote

    7. December 21, 2010 #7
      Alfa1
      • View Profile
      • View Forum Posts
      • View Blog Entries
      • View Articles
      Alfa1 is offline
      Distinguished Member
      Join Date
      September 26, 2007
      Posts
      584
      Rep Power
      257
      I understand. NuWiki had that annoying issue, my members frequently complained about. i.e. if you have an article for 'bear' and someone writes 'bearing', then the first 4 characters of the word 'bearing' would become an autolink to the article. This becomes more annoying when you have similar articles.
      Reply With Quote Reply With Quote

    8. December 28, 2010 #8
      InformationNirvana
      • View Profile
      • View Forum Posts
      • View Blog Entries
      • View Articles
      InformationNirvana is offline
      Regular Member
      Join Date
      April 11, 2007
      Location
      Canada eh !
      Posts
      130
      Rep Power
      566
      another important rule of wikis is ... keep the articles short !
      Reply With Quote Reply With Quote

    9. December 28, 2010 #9
      pegasus
      • View Profile
      • View Forum Posts
      • View Blog Entries
      • Visit Homepage
      • View Articles
      pegasus is offline
      VaultWiki Team
      Join Date
      March 28, 2004
      Location
      New York, NY
      Posts
      2,934
      Blog Entries
      18
      Rep Power
      659
      Yes, I have a test article that is over 500,000 characters long and it takes over 10 seconds to load. Not much that can be done on the coding side, the article is just too long.
      - lead developer for VaultWiki
      Reply With Quote Reply With Quote

    10. December 28, 2010 #10
      Alfa1
      • View Profile
      • View Forum Posts
      • View Blog Entries
      • View Articles
      Alfa1 is offline
      Distinguished Member
      Join Date
      September 26, 2007
      Posts
      584
      Rep Power
      257
      But the whole point of it is to accumulate comprehensive articles. Hahaha.
      Reply With Quote Reply With Quote

    11. January 1, 2011 #11
      InformationNirvana
      • View Profile
      • View Forum Posts
      • View Blog Entries
      • View Articles
      InformationNirvana is offline
      Regular Member
      Join Date
      April 11, 2007
      Location
      Canada eh !
      Posts
      130
      Rep Power
      566
      Quote Originally Posted by Alfa1 View Post
      But the whole point of it is to accumulate comprehensive articles. Hahaha.
      Break up comprehensive articles into smaller articles.
      Reply With Quote Reply With Quote

    Similar Threads

    1. How do I get VW3 to load bullet.gif from https?
      By Alfa1 in forum VaultWiki Questions
      Replies: 6
      Last Post: August 22, 2014, 7:37 AM
    2. Posting a wiki page to as an article to CMS
      By nobodieshero in forum VaultWiki Questions
      Replies: 2
      Last Post: April 11, 2013, 2:30 PM
    3. Google Analytics takes forever to load
      By Alfa1 in forum VaultWiki Questions
      Replies: 4
      Last Post: December 15, 2010, 7:21 PM
    4. Promote a wiki article to CMS front page
      By stev in forum General Discussion
      Replies: 6
      Last Post: December 7, 2010, 3:57 PM
    5. Article load error message...
      By creativeLiquid in forum VaultWiki Questions
      Replies: 4
      Last Post: September 8, 2010, 12:41 AM

    Tags for this Thread

    are, article, articles, difference, doing, find, generated, gives, here, hey, its, know, loading, mysql, one, page, php, quote, seconds, spending, there, things, this, time, were, what, when, with, you

    View Tag Cloud

    Bookmarks

    Bookmarks
    • Submit to Digg Digg
    • Submit to del.icio.us del.icio.us
    • Submit to StumbleUpon StumbleUpon
    • Submit to Google Google

    Posting Permissions

    • 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 Off
    • [VIDEO] code is
    • HTML code is Off

    Forum Rules

    • Contact Us
    • License Agreement
    • Privacy
    • Terms
    • Top
    All times are GMT -4. The time now is 8:44 PM.
    This site uses cookies to help personalize content, to tailor your experience, and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Learn more… Accept Remind me later
  • striker
    Powered by vBulletin® Version 4.2.5 Beta 2
    Copyright © 2023 vBulletin Solutions Inc. All rights reserved.
    Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2023 DragonByte Technologies Ltd.
    Copyright © 2008 - 2013 VaultWiki Team, Cracked Egg Studios, LLC.